Data Scraping inside loop

Hello,

I have an excel file that contains several variables that I want to use to perform a web search. I use “read range” to read the data from the Excel table and “for each row”. In total I would like to do three searches. For each search i want to apply Data Scraping and save the results in a separate Excel file.

However, the data scraping does not work properly. When I use the Data Scraping Wizard, everything works perfectly. But the transfer to the Excel spreadsheet does not work properly. On the first pass data is mostly transferred, after that the selector becomes invalid. It looks like the data scraping always works only for the first search, but is not taken over for the other search attributes. I compared selectors for different searches but could not find any differences between them. The page URL is not changing for the different searches. What could be the problem? I have attached a picture of the selector.

Thanks for the help

Hi @Tris_H

Are there any other Attributes present in the selectors.

Thanks.

Hello,

can you please try to remove the css selector and try again?

Thanks!
Athira

1 Like

Hi,
thanky for your answer. There are no other selectors. The Data Scraping is always working one time and then the selector is “red”/invalid

Hi,
thank you for helping!
Yes i already tried this but unfortunately, it’s not working

This is my XML File from my Data Scraping

You said it’s always working for the first value from excel. So if you rearrange the values. will it still work the first time ?

1 Like

No when i rearrange the values it’s not working anymore… It seems like the Data Scraping is only limited to the attributes of the first search and is not working in the loop with the other search attributes…

So the page is not constant and is changing. So can you give the second value in excel manually into the page and then try to scrape and compare the selectors and XML ?

Thanks!
Athira

1 Like

Yes i tried, but there are no differences in the selectors as well as in the XML…

I tried it now without a loop, so a seperate Excel Sheet for each Search and two times Data Scraping. The strange thing is that this time the data scraping results of the second search were entered into both Excel sheets, although the data scraping was performed twice.

That’s strange! You are using different datatables for both data scraping, right?

1 Like

Yes. I tried it now again with a loop but only with one search attribute. Everything worked fine. Then i changed the values and tried again. The new parameters are filled in in the web search, but the Data Scraping results remain the same from the search with the first parameters… i really dont understand it. It seems like the Data Scraping is always fixed to the values when i used the Extracting Wizard but do not adapt to new search results.

@Tris_H

Just to check, since I had not the same, but a similar issue:

Extracting a DataTable into a loop, seems to work a in a bit “not natural way”, since we would expect every extraction to be done from 0.

My issue was that within a retry scope, if an extraction was done into the variable “A” and during the retry, a new extraction was done into the same variable “A”, on the 1st execution, the variable was empty, so everything was scraped as expected. But on the 2nd loop, the variable already had some value, and instead of scraping new data, and “overwriting” the old data, UiPath did some kind of “Merge” instead.

My solution (not sure if it will help, but it did on my end) was to add a “var_datatable = Nothing” activity (assign), to make sure that inside each loop, the dataTable is clean and does not carry over any information from previous loops.

Hope it helps!

image

1 Like

Hey, thank you very much for your help!

I made sure that the DataTable is empty after every loop with “Clear DataTable”. I think thats almost the same

What i found out:

When i close the page from which the Data Scraping was done (after the extraction for sure and when the robot is not running) the selectors is becoming invalid… i want to scrape prices from different insurances from a comparison portal. Could it be that they use something to protect against Data Scraping and thats why it’s not working? Thank you all for your help

The Solution was the “leaf” selector. The selector wasn’t activated but there i could set a dynamic selector. Thank you all for your help

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.