checking needsUpdate()
This commit is contained in:
@@ -162,7 +162,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<h2 class="heading"></h2>
|
<h2 class="heading"></h2>
|
||||||
<p>
|
<p>
|
||||||
<b>Check out your batch code</b> (Last updated: March 4, 2022)
|
<b>Check out your batch code</b> (Last updated: <span id="last_updated">March 4, 2022</span>)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<table class="display" id="batchCodeTable">
|
<table class="display" id="batchCodeTable">
|
||||||
|
|||||||
@@ -452,7 +452,7 @@
|
|||||||
<dt>Datensatz:</dt>
|
<dt>Datensatz:</dt>
|
||||||
<dd><a href="https://www.intensivregister.de/#/aktuelle-lage/downloads" target="_blank">Landkreis-Daten</a></dd>
|
<dd><a href="https://www.intensivregister.de/#/aktuelle-lage/downloads" target="_blank">Landkreis-Daten</a></dd>
|
||||||
<dt>Datenstand:</dt>
|
<dt>Datenstand:</dt>
|
||||||
<dd>05.03.2022, 12:38 Uhr</dd>
|
<dd id="Datenstand">05.03.2022, 12:38 Uhr</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,42 @@
|
|||||||
"pd.set_option('display.max_columns', None)"
|
"pd.set_option('display.max_columns', None)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "1dbf9321",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from bs4 import BeautifulSoup\n",
|
||||||
|
"import requests\n",
|
||||||
|
"import re\n",
|
||||||
|
"from dateutil.parser import parse\n",
|
||||||
|
"\n",
|
||||||
|
"def needsUpdate():\n",
|
||||||
|
" return _getLastUpdatedHowbadismybatch() < _getLastUpdatedOriginal()\n",
|
||||||
|
" \n",
|
||||||
|
"def _getLastUpdatedHowbadismybatch():\n",
|
||||||
|
" return _getLastUpdated(\n",
|
||||||
|
" url = \"https://knollfrank.github.io/HowBadIsMyBatch/batchCodeTable.html\",\n",
|
||||||
|
" getDateStr = lambda soup: soup.find(id = \"last_updated\").text)\n",
|
||||||
|
"\n",
|
||||||
|
"def _getLastUpdatedOriginal():\n",
|
||||||
|
" def getDateStr(soup):\n",
|
||||||
|
" lastUpdated = soup.find(string = re.compile(\"Last updated\"))\n",
|
||||||
|
" return re.search('Last updated: (.+).', lastUpdated).group(1)\n",
|
||||||
|
"\n",
|
||||||
|
" return _getLastUpdated(url = \"https://vaers.hhs.gov/data/datasets.html\", getDateStr = getDateStr)\n",
|
||||||
|
"\n",
|
||||||
|
"def _getLastUpdated(url, getDateStr):\n",
|
||||||
|
" htmlContent = requests.get(url).text\n",
|
||||||
|
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
||||||
|
" dateStr = getDateStr(soup)\n",
|
||||||
|
" return parse(dateStr).date()\n",
|
||||||
|
"\n",
|
||||||
|
"print('needsUpdate: ', needsUpdate())"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
Reference in New Issue
Block a user