refactoring
This commit is contained in:
@@ -38,10 +38,10 @@
|
||||
"from time import sleep\n",
|
||||
"from selenium import webdriver\n",
|
||||
"\n",
|
||||
"INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
|
||||
"\n",
|
||||
"class DateProvider:\n",
|
||||
" \n",
|
||||
" INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
|
||||
"\n",
|
||||
" def __init__(self):\n",
|
||||
" self.lastUpdatedIntensivstationen = None\n",
|
||||
" self.lastUpdatedOriginal = None\n",
|
||||
@@ -54,7 +54,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",
|
||||
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, INTENSIVSTATIONEN_DATE_FORMAT)\n",
|
||||
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, DateProvider.INTENSIVSTATIONEN_DATE_FORMAT)\n",
|
||||
" \n",
|
||||
" return self.lastUpdatedIntensivstationen\n",
|
||||
"\n",
|
||||
@@ -110,7 +110,7 @@
|
||||
" 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",
|
||||
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))\n",
|
||||
"\n",
|
||||
" with open(file, \"w\") as fp:\n",
|
||||
" fp.write(str(soup))"
|
||||
|
||||
Reference in New Issue
Block a user