You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

UiPath自动化网页数据提取求助:将指定字段导出至Excel

Hey there! Let's work through this UiPath automation challenge together—since you're new to the tool, I’ll break it down into simple, actionable steps that you can follow easily.

UiPath Automation Step-by-Step Guide: Extract Portal Data to Excel

1. Pre-requisites & Setup

  • First, make sure you have the necessary UiPath packages installed:
    • UiPath.Excel.Activities (for Excel operations)
    • UiPath.Web.Activities (for web automation)
      You can grab these via the Manage Packages option in UiPath Studio—just search for the names and install them.
  • Spend a minute navigating your target portal to get familiar with how records are laid out: Are they in an HTML table? Or individual cards? Knowing this will make data extraction smoother.

2. Get User Input for Record Count

  • Drag an Input Dialog activity onto your workflow.
    • Set the Prompt to something like: "Please enter the number of records you want to extract:"
    • Store the user's input in a string variable first, then convert it to an integer (since we’ll use it for counting). For example:
      int_RecordCount = CInt(InputDialog_Result.ToString)
      
  • Pro tip: Add a quick validation step with an If activity to check if the input is a valid number (use IsNumeric(InputDialog_Result)). If not, show a message asking the user to enter a number and loop back to the input dialog.

3. Extract Data from the Portal

How you extract data depends on how records are displayed on the portal—here are the two most common scenarios:

Scenario A: Records are in an HTML Table

  • Use UiPath’s built-in Data Scraping wizard (click the Data Scraping button in the Design tab) to automate this:
    1. Select the first instance of CompanyName, then select the second instance—UiPath will automatically detect the table structure.
    2. Repeat this for BrokerName, Address, and Phone to add all required columns.
    3. When prompted for the maximum number of records to extract, enter your int_RecordCount variable.
    4. The wizard will generate an Extract Data activity, which stores the results in a DataTable (let’s call it dt_ExtractedRecords).

Scenario B: Records are in Individual Cards

  • If records are in separate cards (not a table), use a loop approach:
    1. Use a Find Children activity to locate all record cards on the page. Set the selector to target the card container (e.g., <webctrl tag='div' class='record-card' />), and store the results in a List<UiElement> variable like list_AllRecords.
    2. Add a For Each loop to iterate over list_AllRecords. To limit the loop to the user-specified count, set the loop’s range to Math.Min(list_AllRecords.Count, int_RecordCount) (this avoids errors if there are fewer records than requested).
    3. Inside the loop, use Get Text activities to extract each field (CompanyName, BrokerName, etc.). Make sure your selectors are relative to the current card (use the Attach Browser activity to anchor to the portal, and build selectors that reference the card element from the loop).
    4. Initialize a DataTable upfront with columns matching your fields, then use Add Data Row inside the loop to add each extracted record to the table.

4. Export Data to Excel

  • Drag a Write Range activity into your workflow.
    • Set the DataTable field to dt_ExtractedRecords.
    • Enter your desired Excel file path (e.g., "C:\YourFolder\CompanyData.xlsx").
    • Check the AddHeaders box—this will write your DataTable column names as the Excel header row.

5. Troubleshooting Common Issues

  • Unstable selectors: Avoid using fixed IDs or dynamic attributes (like random numbers) in your selectors. Instead, use stable attributes like class, tag, or innertext to make them more reliable.
  • Pagination: If the portal splits records across pages, add logic to check if you’ve extracted enough records. If not, click the "Next Page" button and repeat the extraction until you hit int_RecordCount or run out of pages.
  • Data formatting: If fields like Phone have weird formatting, use string manipulation activities (like Replace or Trim) to clean up the data before adding it to the DataTable.

内容的提问来源于stack exchange,提问作者Bala Ashokan

火山引擎 最新活动