refactoring
This commit is contained in:
@@ -38,10 +38,10 @@
|
|||||||
"from time import sleep\n",
|
"from time import sleep\n",
|
||||||
"from selenium import webdriver\n",
|
"from selenium import webdriver\n",
|
||||||
"\n",
|
"\n",
|
||||||
"INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
|
|
||||||
"\n",
|
|
||||||
"class DateProvider:\n",
|
"class DateProvider:\n",
|
||||||
" \n",
|
" \n",
|
||||||
|
" INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
|
||||||
|
"\n",
|
||||||
" def __init__(self):\n",
|
" def __init__(self):\n",
|
||||||
" self.lastUpdatedIntensivstationen = None\n",
|
" self.lastUpdatedIntensivstationen = None\n",
|
||||||
" self.lastUpdatedOriginal = None\n",
|
" self.lastUpdatedOriginal = None\n",
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
" htmlContent = requests.get(\"https://knollfrank.github.io/HowBadIsMyBatch/intensivstationen.html\").text\n",
|
" htmlContent = requests.get(\"https://knollfrank.github.io/HowBadIsMyBatch/intensivstationen.html\").text\n",
|
||||||
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
||||||
" dateStr = soup.find(id = \"Datenstand\").text\n",
|
" dateStr = soup.find(id = \"Datenstand\").text\n",
|
||||||
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, INTENSIVSTATIONEN_DATE_FORMAT)\n",
|
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, DateProvider.INTENSIVSTATIONEN_DATE_FORMAT)\n",
|
||||||
" \n",
|
" \n",
|
||||||
" return self.lastUpdatedIntensivstationen\n",
|
" return self.lastUpdatedIntensivstationen\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
" with open(file) as fp:\n",
|
" with open(file) as fp:\n",
|
||||||
" soup = BeautifulSoup(fp, 'lxml')\n",
|
" soup = BeautifulSoup(fp, 'lxml')\n",
|
||||||
"\n",
|
"\n",
|
||||||
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(INTENSIVSTATIONEN_DATE_FORMAT))\n",
|
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))\n",
|
||||||
"\n",
|
"\n",
|
||||||
" with open(file, \"w\") as fp:\n",
|
" with open(file, \"w\") as fp:\n",
|
||||||
" fp.write(str(soup))"
|
" fp.write(str(soup))"
|
||||||
|
|||||||
Reference in New Issue
Block a user