refactoring
This commit is contained in:
@@ -24,10 +24,12 @@
|
|||||||
"from bs4 import BeautifulSoup\n",
|
"from bs4 import BeautifulSoup\n",
|
||||||
"import requests\n",
|
"import requests\n",
|
||||||
"import re\n",
|
"import re\n",
|
||||||
"from dateutil.parser import parse\n",
|
"from datetime import datetime\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class DateProvider:\n",
|
"class DateProvider:\n",
|
||||||
" \n",
|
" \n",
|
||||||
|
" DATE_FORMAT = \"%B %d, %Y\"\n",
|
||||||
|
"\n",
|
||||||
" def __init__(self):\n",
|
" def __init__(self):\n",
|
||||||
" self.lastUpdated = None\n",
|
" self.lastUpdated = None\n",
|
||||||
" self.lastUpdatedDataSource = None\n",
|
" self.lastUpdatedDataSource = None\n",
|
||||||
@@ -59,7 +61,7 @@
|
|||||||
" htmlContent = requests.get(url).text\n",
|
" htmlContent = requests.get(url).text\n",
|
||||||
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
|
||||||
" dateStr = getDateStr(soup)\n",
|
" dateStr = getDateStr(soup)\n",
|
||||||
" return parse(dateStr).date()"
|
" return datetime.strptime(dateStr, DateProvider.DATE_FORMAT)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -459,6 +461,23 @@
|
|||||||
" 'lxml'))\n"
|
" 'lxml'))\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f02dddfe",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def saveLastUpdatedBatchCodeTable(lastUpdated):\n",
|
||||||
|
" def setLastUpdated(soup):\n",
|
||||||
|
" soup.find(id = \"last_updated\").string.replace_with(lastUpdated.strftime(DateProvider.DATE_FORMAT))\n",
|
||||||
|
" return soup\n",
|
||||||
|
"\n",
|
||||||
|
" HtmlTransformerUtil().applySoupTransformerToFile(\n",
|
||||||
|
" file = \"../docs/batchCodeTable.html\",\n",
|
||||||
|
" soupTransformer = setLastUpdated)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -953,16 +972,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"countries = sorted(internationalVaersCovid19['COUNTRY'].unique())"
|
"countries = sorted(internationalVaersCovid19['COUNTRY'].unique())\n",
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "1c518028",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"countryOptions = ['<option value=\"Global\" selected>Global</option>'] + getCountryOptions(countries)"
|
"countryOptions = ['<option value=\"Global\" selected>Global</option>'] + getCountryOptions(countries)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -976,6 +986,16 @@
|
|||||||
"saveCountryOptions(countryOptions)"
|
"saveCountryOptions(countryOptions)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "9c7485b5",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"saveLastUpdatedBatchCodeTable(dateProvider.getLastUpdatedDataSource())"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
Reference in New Issue
Block a user