Created
November 17, 2020 23:11
-
-
Save NicolaiSoeborg/ddef324e11c44acc7a32634d28bc139a to your computer and use it in GitHub Desktop.
Scrape smittestop status
This file contains hidden or 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 re | |
import time | |
import httpx | |
URL = "https://smittestop.dk/status/" | |
r = httpx.get(URL) | |
assert r.status_code == 200, f'{r.status_code}: {r.content}' | |
# Antal downloads af smitte|stop: <strong data-v-e17f8414>1.832.245</strong> | |
# Antal smittemeldinger i appen: <strong data-v-e17f8414>14.365</strong> | |
pattern = re.compile(r'\>(?P<name>[^>]+): \<strong data-v-[a-z0-9]+\>(?P<num>[0-9\.]+)\</strong\>') | |
print(f'\nTime:\t{int(time.time())}') | |
for k, v in pattern.findall(r.content.decode()): | |
print(f'{k}:\t{v}') | |
# I'm scraping this every hour. Contact me to get the data :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment