#!/usr/bin/env python3 import scrape_common as sc print('GL') d = sc.download('https://www.gl.ch/verwaltung/finanzen-und-gesundheit/gesundheit/coronavirus.html/4817') sc.timestamp() d = d.replace(' ', ' ') d = d.replace('ä', 'ä') d = sc.filter(r'Fallzahlen\s*Kanton\s*Glarus.+Update|Bestätigte\s*Fälle|Wahrscheinliche\s*Fälle|Hospitalisierungen|Verstorbene', d) # <li><strong><a href="#Fallzahlen">Fallzahlen Kanton Glarus</a> (Update 22.03.2020, 13.30 Uhr)</strong></li> #... # <h2><strong><a id="Fallzahlen" name="Fallzahlen"></a>Coronavirus: Update Kanton Glarus</strong></h2> # <h2>Bestätigte Fälle: <strong>31</strong> </h2> # <h2>Wahrscheinliche Fälle: <strong>--</strong></h2> # <h2>Hospitalisierungen: <strong>3</strong> </h2> # 2020-03-26 """ <h2><strong><a id="Fallzahlen" name="Fallzahlen"></a>Coronavirus: Update Kanton Glarus</strong><br /> (Stand: 25.3.2020, 13:30 Uhr)</h2> <h2>Bestätigte Fälle: <strong>40 </strong>(Vortag: 33) <br /> Hospitalisierungen: <strong>2</strong> (Vortag: 3)</h2> <p>Die Zahl der bestätigten Fälle umfasst die seit Messbeginn erfassten Personen, die positiv auf COVID-19 getestet wurden. Bereits wieder genesene Personen sind in diesen Zahlen ebenfalls enthalten.</p> """ # 2020-04-03 # Note, that it misses numbers for hospitalized on this day / time. """ <h2><strong><a id="Fallzahlen" name="Fallzahlen"></a>Coronavirus: Update Kanton Glarus</strong><br /> (Stand: 3.4.2020, 13:30 Uhr)</h2> <h2>Bestätigte Fälle: <strong>59 </strong>(+1) <br /> Personen in Spitalpflege: <strong>5 </strong>(+/-0) <br /> Verstorbene Personen: <strong>2 </strong>(+/-0)</h2>
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re import sys import scrape_common as sc # The list of articles is also available on https://www.gd.bs.ch/medienseite/medienmitteilungen.html URL = sc.download("https://www.gd.bs.ch/", silent=True) URL = sc.filter( r'Tagesbulletin.*Corona.*\d+\s*bestätigte\s*(Fälle|Infektionen)', URL) # 2020-03-25, List of sub-articles: """ <a href="/nm/2020-tagesbulletin-coronavirus-466-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 466 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-414-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 414 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-376-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 376 bestätigte Fälle im Kanton Basel-Stadt</a> """ url = 'https://www.gd.bs.ch/' + sc.filter(r'href', URL).split('"')[1] dd = sc.DayData(canton='BS', url=url) d = sc.download(url, silent=True) d = d.replace('ä', 'ä') d = d.replace('ö', 'ö') d = d.replace(' ', ' ') # 2020-03-25 """ <p>Das Gesundheitsdepartement Basel-Stadt meldet mit Stand Mittwoch, 25. März 2020, 10 Uhr, insgesamt 466 positive Fälle von Personen mit Wohnsitz im Kanton Basel-Stadt sowie drei weitere Todesfälle. </p> """
#!/usr/bin/env python3 import urllib.parse import scrape_common as sc main_url = 'https://www.vs.ch/de/web/coronavirus' d = sc.download(main_url, silent=True) d = d.replace(' ', ' ') d = d.replace('ä', 'ä') d = sc.filter(r'bestätigte\s*Fälle', d) # 2020-03-21 """ <p>21.03.2020: Derzeit gibt es 359 bestätigte Fälle von Coronavirus-Infektionen im Kanton. Insgesamt hat das Virus bisher den Tod von 9 Personen im Wallis verursacht.</p> """ # 2020-03-29 """ ... <p>29.03.2020: Derzeit gibt es 964 bestätigte Fälle von Coronavirus-Infektionen im Kanton. Insgesamt hat das Virus bisher den Tod von 21 Personen im Wallis verursacht. Eine Übersicht über die epidemiologische Lage im Wallis ist ... """ dd = sc.DayData(canton='VS', url=main_url) dd.datetime = sc.find(r'<p>\s*([0-9]+\.[0-9]+\.202[0-2]):\s*Derzeit', d) dd.cases = sc.find(r'\b([0-9]+)\s*bestätigte\s*Fälle', d) dd.deaths = sc.find(r'Tod\s*von\s*([0-9]+)\s*Person', d) # Download list of PDFs with statistics updated daily d = sc.download('https://www.vs.ch/de/web/coronavirus/statistiques', silent=True) # 2020-04-02 (but also earlier) """
#!/usr/bin/env python3 import scrape_common as sc import sys print('BS') # The list of articles is also available on https://www.gd.bs.ch/medienseite/medienmitteilungen.html URL = sc.download("https://www.gd.bs.ch/") URL = sc.filter(r'Tagesbulletin.*Corona', URL) # 2020-03-25, List of sub-articles: """ <a href="/nm/2020-tagesbulletin-coronavirus-466-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 466 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-414-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 414 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-376-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 376 bestätigte Fälle im Kanton Basel-Stadt</a> """ URL = sc.filter(r'href', URL) URL = URL.split('"')[1] d = sc.download(f'https://www.gd.bs.ch/{URL}') sc.timestamp() d = d.replace('ä', 'ä') d = d.replace('ö', 'ö') d = d.replace(' ', ' ') # 2020-03-25 """ <p>Das Gesundheitsdepartement Basel-Stadt meldet mit Stand Mittwoch, 25. März 2020, 10 Uhr, insgesamt 466 positive Fälle von Personen mit Wohnsitz im Kanton Basel-Stadt sowie drei weitere Todesfälle. </p> """
#!/usr/bin/env python3 import scrape_common as sc print('AG') # From the new website: d = sc.download( 'https://www.ag.ch/de/themen_1/coronavirus_2/alle_ereignisse/alle_ereignisse_1.jsp' ) sc.timestamp() d = "\n".join(d.split('<article')) d = sc.filter(r'Neues Lagebulletin', d) # Use non-greedy match. print('Date and time:', sc.find(r'class="timeline__time" datetime="00(.*?00)"', d)) print('Confirmed cases:', sc.find(r'zurzeit ([0-9]+) best(ä|ä)tigte F(ä|ä)lle', d)) print('Hospitalized:', sc.find(r'([0-9]+) Person(en)? sind zurzeit hospitalisiert', d)) print( 'ICU:', sc.find(r'([0-9]+) Person(en)?( werden)? auf Intensivstationen behandelt', d)) print('Vent:',
#!/usr/bin/env python3 from bs4 import BeautifulSoup import collections import csv from io import StringIO import re import scrape_common as sc print('ZG') d = sc.download('https://www.zg.ch/behoerden/gesundheitsdirektion/amt-fuer-gesundheit/corona') sc.timestamp() soup = BeautifulSoup(d, 'html.parser') d = sc.filter(r'Infizierte Personen|Genesene Personen|Verstorbene Personen|Stand:', d) date_time_string = sc.find(r'Stand:? ([^<]+ Uhr)<', d) last_update = None matches = re.search(r'(\d+)\.(\d+)\.(\d+)', date_time_string) if matches: last_update = f"{int(matches[1]):02d}.{int(matches[2]):02d}.{matches[3]}" detailed_stats = soup.find("a", text=re.compile("Detaillierte Statistik")) found_last_day = False if detailed_stats and last_update is not None: d_detailed_stats = sc.download(detailed_stats['href']) csv_path = sc.find(r'csv_path:"([^"]+)"', d_detailed_stats) if csv_path.startswith('/'): csv_url = f"https://www.zg.ch/{csv_path}" else: csv_url = csv_path
#!/usr/bin/env python3 import scrape_common as sc print('SH') # A JavaScript content loaded from https://sh.ch/CMS/Webseite/Kanton-Schaffhausen/Beh-rde/Verwaltung/Departement-des-Innern/Gesundheitsamt-3209198-DE.html d = sc.download( 'https://sh.ch/CMS/content.jsp?contentid=3209198&language=DE&_=1584807070095' ) sc.timestamp() d = sc.filter('data_post_content', d) d = d.replace('\\n', '\n') d = d.replace(' ', ' ') d = d.replace('ä', 'ä') # 2020-03-25 """ "data_post_content":"<p class=\"post_text\">Im Kanton Schaffhausen gibt es aktuell (Stand 25.03.2020 08:00 Uhr) <strong>34 bestätige Coronavirus-Fälle<\/strong>.<\/p> """ # 2020-03-29 """ "data_post_content":""<p class=\"post_text\">Im Kanton Schaffhausen gibt es aktuell (Stand 29.03.2020, 08:00 Uhr) <strong> 40 bestätige Coronavirus-Fälle</strong>.< """ # 2020-04-03 """ "data_post_content":"<p class=\"post_text\">Im Kanton Schaffhausen gibt es aktuell (Stand 02.04.2020): <\/p>\n\n<p class=\"post_text\"><strong>Anzahl Infizierte Fälle (kumuliert): 47<\/strong><\/p>\n\n<p class=\"post_text\"><strong>Anzahl Hospitalisationen Isolation (aktuell): 15<\/strong><\/p>\n\n<p class=\"post_text\"><strong>Anzahl Hospitalisationen Intensiv (aktuell): 3<\/strong><\/p>\n\n<p class=\"post_text\"><strong>Verstorbene (kummuliert): 1<\/strong><\/p>\n\n<p .... """ print('Date and time:',
#!/usr/bin/env python3 import re import sys import scrape_common as sc # The list of articles is also available on https://www.gd.bs.ch/medienseite/medienmitteilungen.html URL = sc.download("https://www.gd.bs.ch/", silent=True) URL = sc.filter(r'Tagesbulletin.*Corona', URL) # 2020-03-25, List of sub-articles: """ <a href="/nm/2020-tagesbulletin-coronavirus-466-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 466 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-414-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 414 bestätigte Fälle im Kanton Basel-Stadt</a> <a href="/nm/2020-tagesbulletin-coronavirus-376-bestaetigte-faelle-im-kanton-basel-stadt-gd.html" target="_self">Tagesbulletin Coronavirus: 376 bestätigte Fälle im Kanton Basel-Stadt</a> """ url = 'https://www.gd.bs.ch/' + sc.filter(r'href', URL).split('"')[1] dd = sc.DayData(canton='BS', url=url) d = sc.download(url, silent=True) d = d.replace('ä', 'ä') d = d.replace('ö', 'ö') d = d.replace(' ', ' ') # 2020-03-25 """ <p>Das Gesundheitsdepartement Basel-Stadt meldet mit Stand Mittwoch, 25. März 2020, 10 Uhr, insgesamt 466 positive Fälle von Personen mit Wohnsitz im Kanton Basel-Stadt sowie drei weitere Todesfälle. </p> """ # There are some extra (or repeated) information in the previous / next paragraphs:
#!/usr/bin/env python3 import scrape_common as sc print('SO') d = sc.download("https://corona.so.ch/") sc.timestamp() d = sc.filter( "Situation Kanton Solothurn.*Stand|Anzahl positiv getesteter Erkrankungsfälle|Verstorben:", d) d = d.replace('<strong>', '').replace('</strong>', '') # 2020-03-23 """ <p class="bodytext"><strong>Situation Kanton Solothurn (Stand 23.03.2020, 12:00)</strong></p><ul><li>Anzahl positiv getesteter Erkrankungsfälle: 95 Personen</li> <li>Verstorben:<strong> </strong>1 Person</li></ul><p class="bodytext"> </p></div></div> """ # 2020-04-02 """ <p class="bodytext"><strong>Situation Kanton Solothurn (Stand 02.04.2020, 0:00 Uhr)</strong></p><ul><li>Anzahl positiv getesteter Erkrankungsfälle: 227 (+11 im Vergleich zum Vortag)</li> <li>Verstorbene Personen:<strong> </strong>3 (keine Veränderung im Vergleich zum Vortag)</li></ul><p class="bodytext"> </p></div></div> """ # 2020-04-03 """ <p class="bodytext"><strong>Situation Kanton Solothurn (Stand 03.04.2020, 0:00 Uhr)</strong></p><ul><li>Anzahl positiv getesteter Erkrankungsfälle: 237 (+10 im Vergleich zum Vortag)</li> <li>Im Kanton hospitalisierte Patientinnen und Patienten: 17 (+3 im Vergleich zum Vortag)</li> <li>Verstorbene Personen:<strong> </strong>3 (keine Veränderung im Vergleich zum Vortag)</li></ul><p class="bodytext"> </p></div></div> """ print("Date and time:", sc.find(r'\(Stand ([^\)]+)\)<', d)) print( "Confirmed cases:", sc.find( r'Anzahl\s*positiv\s*getesteter\s*Erkrankungsfälle\s*:\s*([0-9]+)\b', d))
#!/usr/bin/env python3 import scrape_common as sc print('BL') main_site = sc.download("https://www.baselland.ch/politik-und-behorden/direktionen/volkswirtschafts-und-gesundheitsdirektion/amt-fur-gesundheit/medizinische-dienste/kantonsarztlicher-dienst/aktuelles/covid-19-faelle-kanton-basel-landschaft") # 2020-03-31, iframe """ <iframe width="100%" class="iframeblock loading" onload="onIframeLoaded(this)" src="https://www.statistik.bl.ch/files/sites/Grafiken/COVID19/20200331_COVID19_BL.htm" scrolling="auto" height="600"></iframe> """ iframe = sc.filter(r'<iframe', main_site) iframe_url = sc.find(r'src="(.+?)"', iframe) d = sc.download(iframe_url) sc.timestamp() # 2020-03-24 """ <pre id="data" style="display:none;"> Datum, Bestätigte Fälle, Verstorbene 28-02-2020,1, 29-02-2020,2, 01-03-2020,2, 02-03-2020,2, ... 21-03-2020,282,3 22-03-2020,289,3 23-03-2020,302,3
#!/usr/bin/env python3 import scrape_common as sc print('NE') d = sc.download( 'https://www.ne.ch/autorites/DFS/SCSP/medecin-cantonal/maladies-vaccinations/Pages/Coronavirus.aspx' ) sc.timestamp() d = sc.filter('Nombre de cas confirmés', d) # 2020-03-25 """ </p><p style="text-align:justify;">  <br></p><p style="text-align:justify;">Le coronavirus COVID-19 (2019-nCoV) est un nouveau coronavirus découvert en décembre 2019 dans la ville de Wuhan dans la province de Hubei au centre de la Chine et responsable d'une large épidémie de pneumonies. Ce virus est apparenté aux coronavirus responsables du SARS et du MERS.</p><p style="text-align:justify;">Le virus provient probablement d'animaux sauvages, a été transmis à l'être humain et se transmet désormais de personne à personne.</p><h3>Quelle est la situation actuelle ?</h3><p style="text-align:justify;">Au niveau mondial, la situation évolue rapidement depuis début janvier (<a title="Lien vers la page web de Johns Hopkins" href="https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6" target="_blank">carte de la situation mondiale</a>). Après la Chine, l'épidémie de maladie de coronavirus COVID-19 atteint désormais tous les continents (Asie, Europe, Amérique du Nord, Amérique du Sud, Australie, Afrique). L'Organisation mondiale de la santé (OMS) parle désormais de pandémie.</p><p style="text-align:justify;">En Suisse, des  cas ont été signalés dans 24 cantons : Appenzell Rhodes-Extérieures, Argovie, Bâle-Campagne, Bâle-Ville, Berne, Fribourg, Genève, Glaris, Grisons, Jura, Lucerne, Neuchâtel, Nidwald, Obwald, Saint-Gall, Schaffouse, Schwyz, Soleure, Tessin, Turgovie, Vaud, Valais, Zug et Zürich. </p><p style="text-align:justify;"><strong><br><span class="ms-rteThemeForeColor-5-0">Suisse   25.03.2020, 08h15</span><br><strong><strong>Nombre de tests positifs : 9'765<br>Nombre de décès : 103<br><strong><strong><strong><strong><strong><strong><br><span class="ms-rteThemeForeColor-5-0">Neuchâtel   25.03.2020, 14h00</span><br>Nombre de cas confirmés : 256 personnes<br>Nombre de décès : 2</strong></strong></strong></strong></strong></strong></strong></strong></strong></p><p style="text-align:justify;"> </p><div class="well"><h3>Pour en savoir plus...<br></h3><p style="text-align:justify;">Étant donné que la situation change très rapidement, veuillez consulter la page web de l'Office fédéral de la santé publique (OFSP) pour obtenir les dernières informations sur le nouveau coronavirus COVID-19, ainsi que la liste des questions fréquemment posées :</p><p style="text-align:justify;"> """ # 2020-03-25, smaller part: """ ... <strong><strong><br><span class="ms-rteThemeForeColor-5-0">Neuchâtel   25.03.2020, 14h00</span><br>Nombre de cas confirmés : 256 personnes<br>Nombre de décès : 2</strong></strong> ... """ print('Date and time:', sc.find(r'>Neuchâtel( )* +([^<]+)<\/span>', d, group=2)) # d2 = d.replace('<br>', '\n') # Use non-greed matching in few places. print( 'Confirmed cases:', sc.find( r'>Neuchâtel.+?Nombre de.*? confirmés (:| | )*([0-9]+) pers', d, group=2))