dancarmoz / israel_moh_covid_dashboard_data

Data pulled from the Israeli Minsitry of Health's COVID-19 dashboard's API.
17 stars 12 forks source link

python version #1

Open evenzur opened 4 years ago

evenzur commented 4 years ago

I'm so newbie on python im ashamed :-) however, the code looks like its compatible only with python 2.7, cause of the thing with the parentsis, isnt it? if so can this be convereted to python 3?

dancarmoz commented 4 years ago

Hi, The purpose of this git is mostly for preserving the previous versions of the dashboard (so they are not gone forever every update), and to provide some interesting tables based on the data. The code is there mostly to provide examples for people who want to manipulate the JSONs (or pull directly from the server) on their own, it is not really meant to be pulled and run locally directly by other people (some parts of the code push to this git, which only I have access to).

My native development environment is indeed 2.7, and I am happy in it (as long as I don't think about how much nicer f-strings would be) and have no intention to migrate currently. The code is also very outdated, the current version running has many more functions (as evidenced by the existence of more csv's than those the current code generates). I might update the code at some point and when I do I'll try to add parentheses to the print statements, which I assume is what you meant. I'm not sure if that's the only incompatibility with python 3, though.

netaneld122 commented 3 years ago

Is there a documentation regarding the different type of queries allowed to be made besides the python script you provided?
How did you figure out the query options?

dancarmoz commented 3 years ago

Hi Netanel, sorry for the late reply, it took me a while to see it (it would have been more visible as a separate issue, it isn't really related). I don't know of any documentation, but how I figured them out is pretty simple: Visit the dashboard webpage in Google Chrome (most other websites will probably have similar features). Launch the developer tools using ctrl+shift+i (or right click and "inspect"). Choose the "Network" tab in the developer tools window, and refresh the page. You will see many networks requests sent. Look for those named "_batch" (or, alternatively, look for those with the largest size). Click on it, then on the right, under "Headers", scroll down until you get to "Request payload". Expand the selection, and there you have it - all queries made by the dashboard itself to its background API.

But actually, these are not all the queries! These are just the queries made when you load the main interface. There are a few things that can be accessed by the dashboard by clicking on the menus, which are not loaded until you request them. One of them is the distribution of infected/isolated "other staff", which is seen by click on the ( i ) button in the very last applet. The rest are the age and gender distributions of deceased/serious/ventilated individuals, which are accessed by changing the selection in the drop down menu in the penultimate applet. For all of these, just do the interactions with the dev tools open, and you will see new "_batch" queries sent, and again you can inspect their request payloads to find the necessary queries.

Or you can guess! Try sending queries that look similar to known ones, maybe you'll hit on something which the backend provides but isn't used by the frontend...

netaneld122 commented 3 years ago

Oh, very cool. Thanks!