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/
We can do this by using pandas read_html function:
This will return a list of all tables found on the website. We can see how many tables it returned using the len() function
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.
We can see that the first table has the data we wanted.
Let’s look through the other tables to see what was returned.
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
Last, we will export the results to Excel
An Excel File will be created
Now we have our data within Excel.