Skip to content
Advertisement

Scraping #document from an iframe tag using beautifulsoup

I am trying to scrape a website for COVID related data. The data is enclosed in an iframe tag. I tried to scrape the results using beautifulsoup but couldn’t extract #document. Here’s my approach

JavaScript

My results:

The end part

Inspect Data from website:

Website HTML code

Can somebody explain that why the #document part is missing from my results?

Advertisement

Answer

However, The Guardian offers an entire .csv file up for grabs, if you take a look at what’s going on in the Developer Tool.

Here’s how to grab data for Covid19 Gloabal Deaths:

JavaScript

And if you swap the last part of the URL with time_series_covid19_confirmed_global.csv that’s what you’re going to get back as a .csv file.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement