refactoring
This commit is contained in:
@@ -6,12 +6,26 @@
|
||||
"id": "9de5907f-18f5-4cb1-903e-26028ff1fa03",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"\n",
|
||||
"module_path = os.path.abspath(os.path.join('..'))\n",
|
||||
"if module_path not in sys.path:\n",
|
||||
" sys.path.append(module_path)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "640be762",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"from urllib import request\n",
|
||||
"import os\n",
|
||||
"from DateProvider import DateProvider\n",
|
||||
"from datetime import datetime\n",
|
||||
"from HtmlTransformerUtil import HtmlTransformerUtil\n",
|
||||
"\n",
|
||||
"pd.set_option('display.max_rows', 100)\n",
|
||||
"pd.set_option('display.max_columns', None)\n",
|
||||
@@ -52,30 +66,6 @@
|
||||
"print('needsUpdate:', needsUpdate)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "03784154",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from bs4 import BeautifulSoup\n",
|
||||
"\n",
|
||||
"class HtmlTransformerUtil:\n",
|
||||
" \n",
|
||||
" def applySoupTransformerToFile(self, file, soupTransformer):\n",
|
||||
" self._writeSoup(soupTransformer(self._readSoup(file)), file)\n",
|
||||
"\n",
|
||||
" def _readSoup(self, file):\n",
|
||||
" with open(file) as fp:\n",
|
||||
" soup = BeautifulSoup(fp, 'lxml')\n",
|
||||
" return soup\n",
|
||||
"\n",
|
||||
" def _writeSoup(self, soup, file):\n",
|
||||
" with open(file, \"w\") as fp:\n",
|
||||
" fp.write(str(soup)) \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in New Issue
Block a user