Web Scraping Tables with Python

Web Scraping Tables with Python



Visit my website to download the sample workbook and program:

Send me an email at david.rudd@letsworkapps.com to learn more about python training.

If you'd rather watch a video of how I did some web scraping using click below

Auditors sometimes need to pull data from web sources. It could be a web service provider or a government website with data important to your business. Here I’ll show you how to pull table data from a website. Here we will pull inflation rate data.

https://www.usinflationcalculator.com/inflation/historical-inflation-rates/

No alt text provided for this image

We can do this by using pandas read_html function:

No alt text provided for this image

This will return a list of all tables found on the website. We can see how many tables it returned using the len() function

No alt text provided for this image


This shows us that there are 3 tables that were returned. We will display each table by using brackets at the end of df_tables. Python starts its numbers at 0.

No alt text provided for this image

We can see that the first table has the data we wanted.

Let’s look through the other tables to see what was returned.

No alt text provided for this image
No alt text provided for this image

We can see that the second and third table isn’t what we need.

Since we see the first table is what we need we’ll save it to the variable df

No alt text provided for this image

Last, we will export the results to Excel

No alt text provided for this image

An Excel File will be created

No alt text provided for this image


Now we have our data within Excel.

No alt text provided for this image








To view or add a comment, sign in

More articles by David Rudd

  • Look up Deleted Customer

    A common task for auditors is comparing two data sets. In this lesson I will compare a customer table to an invoice…

    1 Comment
  • Automate SAP with Excel

    This will probably be the only VBA lesson I do, but I think automating SAP is significantly easier using VBA because…

    9 Comments
  • Use Python to Add References to Audit Workpapers

    Sometimes as an auditor, we will get a lot of documents. It helps to organize the workpapers by numbering them so they…

  • Address Verification Using Python & Smarty Address Verification

    To download my sample workbook visit my site: If you'd like a video showing how I organized and ran the code:…

  • Detecting Conflicts of Interest with Python

    One way to identify conflicts of interest is to compare employee data to vendor data to see if there is an employee has…

Others also viewed

Explore content categories