英文:
Extract table data from the hyperlinks in a column on a website using UI Path
问题
我有一个网站,上面有表格数据(每页4列,每页50行,共10到15页数据,我可以浏览每页来抓取并将这些表格数据放入Excel表格中)。
我的用例是,这个表格中有一列包含超链接“详情”,点击后会跳转到一个包含一些表格数据的页面。我想将这些数据复制到Excel中。
我尝试了多种工作流程,但不幸的是都没有成功。
希望能得到帮助。
英文:
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
答案1
得分: 0
假设您在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>
以及在每个详情页(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>
首先,使用“Use Application/Browser”活动和“Extract Table Data”活动打开页面并获取表格:
Extract Table Data
会自动将URL保存到额外的列中:
接下来,使用“ForEach Row in DataTable”活动循环遍历表格的每一行,使用“Go To URL”活动转到链接的页面,然后使用另一个“Extract Table Data”活动获取下一个表格:
根据您希望如何在Excel中显示结果,您可能希望使用“Write DataTable to Excel”活动。如果您能在您的问题中提供有关输出应该是什么的更多信息,那么这个答案可以扩展以包括那方面的信息。
英文:
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:
The Extract Table Data
automatically saves the URL to an extra column:
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:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论