Skip to content

Instantly share code, notes, and snippets.

@alexdevero
Created April 26, 2020 12:26
Show Gist options
  • Save alexdevero/a14a1c536e28fc94e35746a22d14294e to your computer and use it in GitHub Desktop.
Save alexdevero/a14a1c536e28fc94e35746a22d14294e to your computer and use it in GitHub Desktop.
Simple script for scrapping covid data from worldometers.info/coronavirus
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