Data Import & Export

How to Automate Website Data Retrieval in Excel using Power Query

Khadija KhanKhadija Khan Nov 3, 2026 870 views

Question details

The user wants to automate the extraction of structured data from websites into a spreadsheet and needs to know the best tools for handling logins, changing layouts, and exporting to CSV.

How to Automate Website Data Retrieval in Excel
Product
Excel
Device & OS
not provided
Scenario
Importing structured table data from web pages into a spreadsheet, potentially navigating authentication, and ultimately saving the data as a CSV file.
Observed behavior
Evaluating whether to use Excel VBA or Power Query to automate browser interactions, handle login screens, and retrieve web data efficiently.
Before you start

Verify that the target website permits automated data retrieval in its Terms of Service, and ensure you have the correct URL and login credentials if authentication is required.

Solution 1Recommended

Use Power Query to Extract Structured Web Data

Power Query is the most reliable and user-friendly tool for importing structured data tables from web pages into Excel.

Power Query is highly recommended over VBA for simple web scraping because it handles data extraction and transformation natively without complex coding. It can also be refreshed easily with a single click.

1
Open Get Data

Navigate to the 'Data' tab on your Excel ribbon. Click on 'Get Data', select 'From Other Sources', and then choose 'From Web'.

2
Enter the URL

In the dialog box that appears, paste the URL of the website containing the data you want to retrieve and click 'OK'.

3
Select Data Tables

The Navigator window will display all available tables found on the webpage. Select the table(s) you need and click 'Load' to import the data into your worksheet.

4
Export to CSV

Once the data is loaded into your sheet, go to 'File' > 'Save As'. Choose your destination folder and select 'CSV (Comma delimited)' from the 'Save as type' dropdown menu to export the data.

Use Power Query to Extract Structured Web Data
Efficient Data Management with WPS Spreadsheet

Import and Export Web Data Easily with WPS Office

WPS Spreadsheet provides powerful built-in tools for importing external data. You can seamlessly connect to web queries, manage structured data, and export your worksheets to CSV format with a highly intuitive interface.

  1. 1. Open Data Import Tool: Launch WPS Spreadsheet, go to the 'Data' tab on the top ribbon, and click on 'Import Data'.
  2. 2. Connect to Web Source: Select the option to import from a Web Query, and enter the URL of the target website into the address bar.
  3. 3. Select and Import: Choose the specific data tables you want to extract from the webpage preview, then click 'Import' to place the data into your spreadsheet.
  4. 4. Save as CSV: Click the 'Menu' button, select 'Save As', choose 'Other Formats', and select 'CSV (Comma delimited)' to export your web data.
Easily import structured data directly from web sources.100% compatible with Microsoft Excel file formats, including .xlsx and .csv.Lightweight application ensures fast processing even for large datasets.Built-in data transformation tools to clean web data effortlessly.
microsoft office alternative - wps office

Frequently Asked Questions

Can Power Query handle websites that require a login?

Yes, Power Query supports basic authentication methods. When you connect to a URL, you can select 'Basic', 'Windows', or 'Web API' credentials. However, for complex web forms, CAPTCHAs, or multi-factor authentication, Power Query might fail, and you may need to use an API or a tool like Selenium.

Why is Power Query generally preferred over VBA for scraping?

Power Query is specifically built for extracting, transforming, and loading (ETL) structured data. It requires no complex coding, handles data formatting natively, and is much less likely to break when website layouts change compared to VBA macros relying on rigid HTML structures.

How do I automatically save my imported web data as a CSV file in Excel?

Once your web data is imported via Power Query, you can save it manually by going to File > Save As and choosing CSV. To fully automate this, you can write a short VBA macro that refreshes the Power Query connection and then uses the 'ActiveWorkbook.SaveAs' command to output the file in the xlCSV format.

What if the website data changes dynamically and isn't captured by Power Query?

If a website uses JavaScript to load data dynamically as you scroll, standard Power Query will only see the initial raw HTML. You can work around this by inspecting the webpage's network traffic (using browser Developer Tools) to find the underlying JSON data API URL and using that URL in Power Query instead.