Search code examples
uipathuipath-studio

Extract table data from the hyperlinks in a column on a website using UI Path


So I have a website which has table data (4 columns and 50 rows per page and 10 to 15 pages of data and I can navigate through each page to scrape and get this table data into an excel)

My use case is, there is a column within this table which has hyperlinks "details" which clicked there is a page which contains some table data. I want this data to be copied to excel.

I tried multiple workflows but no luck unfortunately.

Any help would be appreciated


Solution

  • Let's assume you have this table at index.html:

    <table id="myTable">
      <tr>
        <th>Month</th>
        <th>Details</th>
      </tr>
      <tr>
        <td>January</td>
        <td><a href="jan.html">Details</a></td>
      </tr>
      <tr>
        <td>February</td>
        <td><a href="feb.html">Details</a></td>
      </tr>
    </table>
    

    And this table in each details page (jan.html, feb.html):

    <table id="myTable2">
      <tr>
        <th>Category</th>
        <th>Amount</th>
      </tr>
      <tr>
        <td>Revenue</td>
        <td>100,000</td>
      </tr>
      <tr>
        <td>Profit</td>
        <td>10,000</td>
      </tr>
    </table>
    

    First, open the page and get the table using the Use Application/Browser activity and an Extract Table Data activity:

    Snippet of the program showing the activities used

    The Extract Table Data automatically saves the URL to an extra column:

    Preview of table data to be extracted

    Loop through each row of the table using the For Each Row in Data Table activity, go to the linked page using the Go To URL activity, and get the next table using another Extract Data Table activity:

    Snippet of the program showing the activities used

    Depending on how you want to display the results in Excel, you'll probably then want to use a Write DataTable to Excel activity. If you can provide more information in your question about what the output should be, this answer could be expanded this answer to include that.