Esempio n. 1
0
#!/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:&nbsp;<strong>31</strong>&nbsp;</h2> 
#      <h2>Wahrscheinliche Fälle:&nbsp;<strong>--</strong></h2> 
#      <h2>Hospitalisierungen:&nbsp;<strong>3</strong>&nbsp;</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&nbsp;</strong>(Vortag: 33)&nbsp;<br /> Hospitalisierungen: <strong>2</strong>&nbsp;(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&nbsp;</strong>(+1)&nbsp;<br /> Personen in Spitalpflege: <strong>5 </strong>(+/-0)&nbsp;<br /> Verstorbene Personen: <strong>2 </strong>(+/-0)</h2> 
Esempio n. 2
0
#!/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('&auml;', 'ä')
d = d.replace('&ouml;', 'ö')
d = d.replace('&nbsp;', ' ')

# 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>
"""
Esempio n. 3
0
#!/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('&nbsp;', ' ')
d = d.replace('&auml;', 'ä')
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.&nbsp;Insgesamt hat das Virus bisher den Tod von 9&nbsp;Personen im Wallis verursacht.</p>
"""

# 2020-03-29
"""
... <p>29.03.2020: Derzeit gibt es 964&nbsp;bestätigte Fälle von Coronavirus-Infektionen im Kanton.&nbsp;Insgesamt hat das Virus bisher den Tod von 21&nbsp;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)
"""
Esempio n. 4
0
#!/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('&auml;', 'ä')
d = d.replace('&ouml;', 'ö')
d = d.replace('&nbsp;', ' ')

# 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>
"""
Esempio n. 5
0
#!/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(ä|&auml;)tigte F(ä|&auml;)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:',
Esempio n. 6
0
#!/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
Esempio n. 7
0
#!/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('&nbsp;', ' ')
d = d.replace('&auml;', 'ä')

# 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&nbsp;best&auml;tige&nbsp;Coronavirus-F&auml;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>&nbsp;40 best&auml;tige&nbsp;Coronavirus-F&auml;lle</strong>.<
"""

# 2020-04-03
"""
        "data_post_content":"<p class=\"post_text\">Im Kanton Schaffhausen gibt es aktuell (Stand 02.04.2020):&nbsp;<\/p>\n\n<p class=\"post_text\"><strong>Anzahl Infizierte F&auml;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:',
Esempio n. 8
0
#!/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('&auml;', 'ä')
d = d.replace('&ouml;', 'ö')
d = d.replace('&nbsp;', ' ')

# 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:
Esempio n. 9
0
#!/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))
Esempio n. 10
0
#!/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
Esempio n. 11
0
#!/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&#58;justify;">&#160;&#160;<br></p><p style="text-align&#58;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&#160;de pneumonies. Ce virus est apparenté aux coronavirus responsables du SARS et du MERS.</p><p style="text-align&#58;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&#58;justify;">Au niveau mondial, la situation évolue rapidement depuis début janvier (<a title="Lien vers la page web de Johns Hopkins" href="https&#58;//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&#160;tous les continents (Asie, Europe, Amérique du Nord, Amérique du Sud, Australie, Afrique). L'Organisation mondiale de la santé (OMS)&#160;parle désormais de pandémie.</p><p style="text-align&#58;justify;">En Suisse, des&#160;&#160;cas ont&#160;été signalés dans&#160;24 cantons &#58;&#160;Appenzell Rhodes-Extérieures, Argovie, Bâle-Campagne, Bâle-Ville, Berne, Fribourg, Genève, Glaris, Grisons, Jura, Lucerne, Neuchâtel,&#160;Nidwald, Obwald, Saint-Gall, Schaffouse, Schwyz, Soleure,&#160;Tessin, Turgovie, Vaud, Valais, Zug et Zürich. </p><p style="text-align&#58;justify;"><strong><br><span class="ms-rteThemeForeColor-5-0">Suisse&#160;&#160; 25.03.2020, 08h15</span><br><strong><strong>Nombre de tests positifs &#58; 9'765<br>Nombre de décès &#58; 103<br><strong><strong><strong><strong><strong><strong><br><span class="ms-rteThemeForeColor-5-0">Neuchâtel&#160;&#160; 25.03.2020, 14h00</span><br>Nombre de cas confirmés &#58;&#160;256 personnes<br>Nombre de décès &#58; 2</strong></strong></strong></strong></strong></strong></strong></strong></strong></p><p style="text-align&#58;justify;">&#160;</p><div class="well"><h3>Pour en savoir plus...<br></h3><p style="text-align&#58;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 &#58;</p><p style="text-align&#58;justify;">
"""

# 2020-03-25, smaller part:
"""
... <strong><strong><br><span class="ms-rteThemeForeColor-5-0">Neuchâtel&#160;&#160; 25.03.2020, 14h00</span><br>Nombre de cas confirmés &#58;&#160;256 personnes<br>Nombre de décès &#58; 2</strong></strong> ...
"""

print('Date and time:',
      sc.find(r'>Neuchâtel(&#160;)* +([^<]+)<\/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 (&#58;|&#160;| )*([0-9]+) pers',
        d,
        group=2))