Created
April 26, 2020 12:26
-
-
Save alexdevero/a14a1c536e28fc94e35746a22d14294e to your computer and use it in GitHub Desktop.
Simple script for scrapping covid data from worldometers.info/coronavirus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import cheerio from 'cheerio' | |
async function getData() { | |
const data = await axios.get('https://www.worldometers.info/coronavirus/') | |
.then(res => res.data) | |
const $ = cheerio.load(data) | |
const cases = $('#maincounter-wrap > .maincounter-number span').html().trim() | |
const deaths = $('#maincounter-wrap + div + #maincounter-wrap > .maincounter-number span').html().trim() | |
const recovered = $('#maincounter-wrap + div + #maincounter-wrap + #maincounter-wrap > .maincounter-number span').html().trim() | |
console.log(cases, deaths, recovered) | |
} | |
getData() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment