How can you scrape data from multiple pages when the URL doesn t change e g Load more button

0 votes

How can you scrape data from multiple pages when the URL doesn't change (e.g., "Load more" button)?

I’m looking for an automated way to scrape data from multiple pages where the URL doesn’t change, such as with a “Load more” button, so I can capture all the data for analysis in Power BI.

4 hours ago in Power BI by Evanjalin
• 33,070 points
9 views

1 answer to this question.

0 votes

You would need to mimic the user interaction that initiates the "Load more" action in order to automate the process of scraping data from multiple pages with a static URL (such as a "Load more" button) and collect the extra data. You would need to use Power Query in conjunction with web scraping techniques or external tools like Python or APIs because Power BI does not have native support for scraping data like this.

Here are a few strategies you can use to deal with this:

Method 1: If JavaScript isn't loading the "Load More" button dynamically, use Power Query with web scraping.
Examine the webpage:

Using browser developer tools, open the webpage in your browser and examine the network traffic. Find an endpoint for an API or a network request that fetches the data when the "Load More" button is clicked.


This will often be an AJAX request or an API call returning data in a JSON format.


Use Power Query to Pull Data from the API:


In Power BI, go to Home > Get Data > Web and enter the API URL.


If the data comes in multiple pages, you can pass the page number or offset as a query parameter in the API URL.


Example URL:

https://example.com/api/data?page=1

Put Pagination Logic into Practice:

Once the first page's data has been obtained, loop through the following pages in Power Query to load all of the data that is available.

To call the API for every page and append the results collectively, you can create a custom function.

Utilize the "Combine" feature in Power Query:

To add the information from every page to a single query result, use the "Combine" feature.

Example Power Query M Code:

let
    PageNumber = 1,  // Starting page
    GetPageData = (page as number) => 
        let
            Source = Json.Document(Web.Contents("https://example.com/api/data?page=" & Text.From(page))),
            Data = Source[data]  // Assuming the data is inside the "data" field
        in
            Data,
    AllPagesData = List.Generate(
        () => [Page = PageNumber, Data = GetPageData(PageNumber)],
        each List.Count([Data]) > 0,
        each [Page = [Page] + 1, Data = GetPageData([Page])],
        each [Data]
    ),
    CombinedData = List.Combine(AllPagesData)
in
    CombinedData

answered 3 hours ago by anonymous
• 33,070 points

Related Questions In Power BI

+1 vote
2 answers
0 votes
1 answer

How can You Change the Value Measure to Show Multiple Measures Dynamically?

You can dynamically change and switch functions ...READ MORE

answered Oct 20, 2020 in Power BI by Gitika
• 65,730 points
2,512 views
+1 vote
1 answer
+1 vote
1 answer

How can you combine Power Pivot with Power Query to perform complex data transformations and load the data into Power BI efficiently?

For really complicated transformations using Power Pivot ...READ MORE

answered Dec 3, 2024 in Power BI by pooja
• 24,450 points
274 views
0 votes
1 answer

Displaying Table Schema using Power BI with Azure IoT Hub

Answering your first question, Event Hubs are ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by nirvana
• 3,090 points
1,772 views
+1 vote
1 answer

Unable to install connector for Power Bi and PostgreSQL

I think the problem is not at ...READ MORE

answered Aug 22, 2018 in Power BI by nirvana
• 3,090 points
3,133 views
+2 votes
2 answers

Migrate power bi collection to power bi embedded

I agree with Kalgi, this method is ...READ MORE

answered Oct 11, 2018 in Power BI by Hannah
• 18,520 points
1,936 views
+1 vote
1 answer

Connect power bi desktop to dataset and create custom reports

Open power bi report nd sign in ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 2,131 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP