How to collect data from different websites

I have a list of website from file which i need to collect a specific data from each of them.
I tried using “for each” but every website has a different xpath.
What would be the most efficient way to do so?

If the xpaths are different you would need to use if-then condition within the for each loop. For example:

Get list of websites into list variable websites
For each element in websites
If element=website1
Open website1
Get xpath1
If element=website2
Open website2
Get xpath2

Perform all other actions you need within that loop for each website

1 Like

I am using the exceptional handling now.For each website, it will search for all the xpaths but it get a little messy.
Would there be an more simpler way?

How about creating a table variable containing address and corresponding xpath?

Then you loop at the table
For each element in table
Open website using address
Get xpath

Hi, Thanks for the suggestion.
I tried using table range but not sure how to proceed…any advice?
Thanks so much in advance.

I have been trying it out but also cannot get it to work. Hopefully @ashapkina can help. My problem is I cannot identify the elements from the table when using the open website and web element actions. I believe it is a combination of nested for each loops and then using rows, elements, items, indexes. It works with key stroke actions as there is an index field but I dont know how to use it in web actions.

See also this thread

I think @timriewe’s approach is correct.
You can store the information in Excel, read it to a table, and use the For Each action to iterate through the websites.
As long as the actions you do in all the websites are the same, it should work.

1 Like

Thanks! The square brackets did the trick in identifying the elements in the table. Can that be found anywhere in the knowledge base? I didnt see it.

Yes, we have a guide on using indexes with lists[RPA+Express+Sunbird]+Get+Value+from+List+by+Index

1 Like

@ashapkina i tried using the steps but got error in the 2nd loop, as in error in the executing the 2nd url.
Where i have gone wrong?

What data you you have in the Excel file?

This is the excel file, the xpath are the contact page of the sites.

What does the error log say?

Press Details>>, copy the text and share here.

It looks like it timed out waiting for the website to load.
You need to set a bigger timeout for the action.

1 Like

It works after i set it to bigger timeout. Thanks!

1 Like