DataScrapting - Problem in extracting data for single and multiple page : clicking next button again and again

I am extracting data from a DataTable and it is working with multiple pages if website has more than one page but if there is data only one page then it is clicking the next button again and again because it has one page only.
I try by using do-while method but not working. How can i use try/catch method and using try/catch will fix this issue?

@zeshanm9,

If it has only one page to scrape the data then don’t indicate next button navigator.

No sometimes when the data is processed so it comes to single page, otherwise it is multiple. so i need to handle both single and multiple pages

Change the MaxNumberofResults property to a number which will be the number of records in one page if it’s always going to be a single page. Else you’ll have to use the same logic.

@Jagdish2593 no it will not always be a single page

If you have the number of results displayed on the page read it and put it on max results, so it will stop after reading all the records.

@Jagdish2593 , i change MaxNumberofResults to 10 (number of records in one page is 10), so now it is working and not clicking the next button again and again.
but it will work like this with multiple pages or it will always get first page only

@c.ciprian yes but by doing this it will work with multiple pages or it will always get first page only with number of records as 10 ?

Just put a variable instead of 10 and read the number of results from the page. Read the 27, put it in the variable so you read the 27 results and stop

1-10 of 27

@c.ciprian what do you mean by Read the 27 ?

Do you have on the page the total number of results? Or can you give the link to the page ?
image

no i dont have the total num of results in the website it is just page number

In the academy there is a nice exercise for your kind of problem. Do not click next, but check if transaction number exists (as page number) and click on it. So on transaction 1 you click and scrape page 1, on transaction 2 you scrape the second page and so on…

ok thanks can you share the academy link please

UiPath Academy - UiPath Academy

Hi! I have a similar issue! The next page button is always clickable–even on the last page. The bot keeps clicking the next page button and scraping the last page repeatedly. I wish these website developers would actually make life easier for us! LOL!

There are 2 sets of data that I can read…

image

The bot reads each one as a single element so the aaname, for example, is 1 of 74 or 1 - 20 of 1,464 depending on which I choose. I’m a newbie to RPA so please provide a clear explanation. Thank you!

Ok… I have resolved this issue in the following way!

  • Use Click activity to navigate to the final page.
  • Use Get Text activity to read the pagination results—74 of 74, in my example above. Assign to a variable—FinalPage, for example.
  • Use Click activity to navigate to the first page.
  • In a Flowchart , perform the following actions:
    • Use Data Scraping activity to extract the exact table or fields on the first page.
      • Change 100 to 0 to capture all results.
      • Select No when prompted if data expands on multiple pages.
    • Use Get Text activity to read current pagination—1 of 74, 2 of 74, and so on for example. Assign to a variable—CurrentPage, for example.
    • Use Flow Decision activity where condition is FinalPage=CurrentPage.
      • If True, the process will continue on as it should.
      • If False, use Click activity to click the Next Page link or button and repeat Flowchart steps.

Below is the sequence of activities in their proper order.