Skip to content
Advertisement

How to iterate through pages while web scraping when URL doesn’t change

I want to obtain a list of Branch and ATMs (only) along with their address.

I am trying to scrape:

JavaScript

This gives me the required information on first page, but I want to do it for all the pages. Can someone suggest?

Advertisement

Answer

Try below approach using python – requests simple, straightforward, reliable, fast and less code is required when it comes to requests. I have fetched the API URL from website itself after inspecting the network section of google chrome browser.

What exactly below script is doing:

  1. First it will take the API URL which is created using, headers, payload and a dynamic parameter in caps then do POST request.

  2. Payload is dynamic you can pass any valid value in the params and the data will be created for you every time you want to fetch something from the site.(!Important do not change value of Page_No parameter).

  3. After getting the data script will parse the JSON data using json.loads library.

  4. Finally it will iterate all over the list of addresses fetched in each iteration or page for ex:- Address, Name, Telephone no., Fax, City etc, you can modify these attributes as per your need.

    JavaScript

Output

Advertisement