Search code examples
google-sheetsweb-scrapinglambdaimportgoogle-query-language

How to get multiple pages table like next page in one sheet in google sheet


How to get 4231 row wise data in 424 pages like next page in one sheet in google sheet.

1 page only fetch 25 rows. in same URL

Total row result found = 4231 results found and showing total page 1 of 424.

URL: https://www.screener.in/screens/41109/all-stocks/?limit=10&page=1

I use this formula to get only 25 records

=IMPORTHTML("https://www.screener.in/screens/41109/all-stocks/%22,%22table")

Screenshot - 1 screenshot already got result

Problem and I get solution screenshot

How to fetch 4231 data in 424 pages in one sheet

Screenshot - 2 Error and get solution screenshot


Solution

  • try:

    =QUERY(REDUCE(INDEX(IMPORTHTML("https://screener.in/screens/41109/all-stocks", "table"), 1), 
     SEQUENCE(10), LAMBDA(x, y, {x; 
     IMPORTHTML("https://screener.in/screens/41109/all-stocks/?limit=25&page="&y, "table")})), 
     "where Col1 matches '[0-9]+'", 1)
    

    where 10 is pages

    enter image description here