adding function saveLastUpdatedIntensivstationen(lastUpdated)
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
"from time import sleep\n",
|
||||
"from selenium import webdriver\n",
|
||||
"\n",
|
||||
"INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
|
||||
"\n",
|
||||
"def needsUpdate():\n",
|
||||
" lastUpdatedIntensivstationen = _getLastUpdatedIntensivstationen()\n",
|
||||
" print('lastUpdatedIntensivstationen:', lastUpdatedIntensivstationen)\n",
|
||||
@@ -51,7 +53,7 @@
|
||||
" htmlContent = requests.get(\"https://knollfrank.github.io/HowBadIsMyBatch/intensivstationen.html\").text\n",
|
||||
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
||||
" dateStr = soup.find(id = \"Datenstand\").text\n",
|
||||
" return datetime.strptime(dateStr, \"%d.%m.%Y, %H:%M Uhr\")\n",
|
||||
" return datetime.strptime(dateStr, INTENSIVSTATIONEN_DATE_FORMAT)\n",
|
||||
"\n",
|
||||
"def _getLastUpdatedOriginal():\n",
|
||||
" html = _getOriginalHtml()\n",
|
||||
@@ -77,6 +79,56 @@
|
||||
"print('needsUpdate: ', needsUpdate)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "963f068b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lastUpdatedOriginal = _getLastUpdatedOriginal()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bc48f4cf",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lastUpdatedOriginal"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "03784154",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from bs4 import BeautifulSoup\n",
|
||||
"\n",
|
||||
"def saveLastUpdatedIntensivstationen(lastUpdated):\n",
|
||||
" file = \"../../docs/intensivstationen.html\"\n",
|
||||
" with open(file) as fp:\n",
|
||||
" soup = BeautifulSoup(fp, 'lxml')\n",
|
||||
"\n",
|
||||
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(INTENSIVSTATIONEN_DATE_FORMAT))\n",
|
||||
"\n",
|
||||
" with open(file, \"w\") as fp:\n",
|
||||
" fp.write(str(soup))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "63be303c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"saveLastUpdatedIntensivstationen(lastUpdatedOriginal)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -115,7 +167,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# FK-TODO: falls needsUpdate = True, dann muß das aktuelle Datum noch automatisch in intensivstationen.html eingesetzt werden.\n",
|
||||
"timeSeries = readTimeseries(download = needsUpdate)\n",
|
||||
"timeSeries"
|
||||
]
|
||||
@@ -234,6 +285,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"kreisValues = sorted(kreisValues)\n",
|
||||
"# FK-TODO: die folgenden Optionen in der Datei intensivstationen.html in das select-Element nach \"Alle Landkreise\" einsetzen \n",
|
||||
"printKreisOptions(kreisValues)"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user