Coder Social home page Coder Social logo

aust-govt-covid19-stats's People

Contributors

jxeeno avatar llui85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aust-govt-covid19-stats's Issues

QLik API Integration

It turns out that that the QLik Sense (the product which powers the graphs on the page) has a remarkably well-documented API which provides data a lot more accurately than the current scraping process using Puppeteer.

Advantages of this approach

  • Decimals will no longer be rounded. For example, the positive test percentage for Australia yesterday was 0.0014373561076329474, but the scraped data is rounded to 0.1
  • Scraping is much faster now - my implementation takes ~12 seconds compared to the current ~1 minute.
  • The API provides a modification datetime as ISO8601, so the regex that looks for a date in the footnote can be now avoided:

let dateStr;
const dateMatches = headerLine.match(/[0-9]+\/[0-9]+\/[0-9]{4}$/);
if(dateMatches){
dateStr = moment(dateMatches[0], 'DD/M/YYYY').format('YYYY-MM-DD');
}
if(!dateStr){
console.error(`Could not match date in header: ${headerLine}`);
return;
}

Unfortunately we still need to hardcode the ID of each graph as graph titles aren't included for some reason, but these don't change often, and will still be stored in the raw data.

I'm happy to open a PR for this sometime in the next week if you'd like me to. You can see my basic implementation here.

Scraper is broken

Hi @jxeeno,

Just letting you know the scraper seems to be down at the moment. From a quick look locally it seems that the QLik server is unexpectedly saying that a few graphs in the page HTML don't exist on the server. Specifically, the right-hand row of the KPI grid is returning a null response from the API.

Screenshot of the issue.

The current code currently doesn't check for an undefined graph handle, which then causes it to send an invalid API request, bringing down the script once it receives an error response. I'll open a PR next year... ๐Ÿ˜†

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.