Having access to up-to-date Coronavirus data can be pretty helpful.
Especially, as worldwide COVID-19 cases continue to rise.
However, this data is sometimes available on websites with inconvenient formats.
Today, we will go over how to use a web scraper to scrape data on COVID-19 cases and extract it as an Excel or JSON file.
Free and Easy Web Scraping
For this project, we will use ParseHub, a free and powerful web scraper than can easily extract data from any website. Make sure to download and install ParseHub before getting started.
Additionally, we will scrape data from Worldometer’s Coronavirus page to extract worldwide data and data per country.
How to Scrape Covid-19 Cases Data
It’s now time to start our web scraping project.
- Open ParseHub, click on new project and enter the URL we will be scraping. The page will be rendered inside the app and you’ll be able to make your first selection.
- Scroll down to the table section of the page and click on the first country name to select it. In this case, that’s actually the “world” region. It will be highlighted in green to indicate that it has been selected.
- The rest of the cells in the list will be highlighted in yellow. Click on the second country in the list (“USA”) to select all the country names. In the left sidebar, rename your selection to “country”.
- Now, click on the PLUS(+) sign next to your country selection and choose the relative select command.
- Using the relative select command, click on the “World” name and then on the number beside it. An arrow will appear to show the association you’re creating. You might need to click on the second name and its number too to create all associations. In the left sidebar, rename your selection to total_cases.
- Repeat steps 4-5 to add every column in the table that you’re interested in. In this case, we will also add Total Cases, New Cases, Total Deaths and Total Recovered. Your project should look somewhat like this:
Running Your Scrape
It’s now time to run our web scraping project and extract the data we’ve selected.
To do this, click on the green Get Data button on the left sidebar. Here you will be able to run, test, or schedule your scrape.
If you’d want to scrape daily numbers for up-to-date data, you can run your project on a daily schedule.
For this example, we will just run it right away.
Closing Thoughts
Once the scrape is completed, you will be able to download it as an Excel or JSON file.
You know now how to scrape up-to-date data on COVID-19 cases.
You can now use this data for anything you’d like. For example, check out this project from tech YouTuber TechWithTim where he used ParseHub to create a Coronavirus voice assistant.
If you run into any issues while putting together your project, reach out to us via the live chat on our website and we’ll be happy to assist you.
Happy Scraping!