covid-19-py
covid-19-py copied to clipboard
Scrape real numbers from ministry website
Get the real numbers every 5 minutes.
Here is the confirmed cases number:
https://www.mspbs.gov.py/covid-19.php

We still need to get sources for the other three numbers
Must check this repo https://github.com/cabupy/covid19-py It is exactly what you need
const cheerio = require("cheerio");
const axios = require("axios");
const https = require("https");
/**
*
* @param {string} text
*/
const extractNumber = text => {
let [_, numstr] = text.split(":");
numstr = numstr.replace("s/g", "");
const num = Number.parseInt(numstr);
return num;
};
const fetchCases = async () => {
const url = "https://www.mspbs.gov.py/covid-19.php";
const agent = new https.Agent({
rejectUnauthorized: false
});
try {
const response = await axios.get(url, {
httpsAgent: agent
});
const html = response.data;
const $ = cheerio.load(html);
const x = $(
"body > div > div:nth-child(5) > div > div:nth-child(1) > h4 > font"
);
const text = x.text();
const confirmed = extractNumber(text);
const deaths = 0;
const recovered = 0;
return { confirmed, deaths, recovered, timestamp: new Date() };
} catch (e) {
console.error(e);
}
};
module.exports = {
fetchCases
};
@jmayalag awesome!
@santiracca can we deploy this in firebase?
https://jmayalag.github.io/covid19-scrape/ You can get the updated json at https://jmayalag.github.io/covid19-scrape/cases.json
It updates every 30 minutes
@jmayalag where do you get the deaths
and recovered
numbers from?
I don't have them. I should probably change them to NA until the health ministry updates it.