diff --git a/scrap/utils/export.py b/scrap/utils/export.py index 5276ae0..014da59 100644 --- a/scrap/utils/export.py +++ b/scrap/utils/export.py @@ -5,19 +5,35 @@ from scrap.utils.types import ScrapResult, ScrapBasicArgument -def export_results_to_json(results: dict[int, ScrapResult], output_path: str, current_time: str): +def export_results_to_json( + results: dict[int, ScrapResult], output_path: str, current_time: str +): os.makedirs(output_path, exist_ok=True) - results = {k: [asdict(councilor) for councilor in v.councilors] for k, v in results.items()} + results = { + k: [asdict(councilor) for councilor in v.councilors] for k, v in results.items() + } - with open(os.path.join(output_path, f"scraping_result_{current_time}.json"), "w", encoding="utf-8") as f: + with open( + os.path.join(output_path, f"scraping_result_{current_time}.json"), + "w", + encoding="utf-8", + ) as f: json.dump(results, f, ensure_ascii=False, indent=4) -def export_results_to_txt(results: dict[int, ScrapResult], output_path: str, current_time: str): +def export_results_to_txt( + results: dict[int, ScrapResult], output_path: str, current_time: str +): os.makedirs(output_path, exist_ok=True) - results = {k: [asdict(councilor) for councilor in v.councilors] for k, v in results.items()} + results = { + k: [asdict(councilor) for councilor in v.councilors] for k, v in results.items() + } - with open(os.path.join(output_path, f"scraping_result_{current_time}.txt"), "w", encoding="utf-8") as f: + with open( + os.path.join(output_path, f"scraping_result_{current_time}.txt"), + "w", + encoding="utf-8", + ) as f: for cid, councilors in results.items(): councilors = "\n".join([c.to_txt() for c in councilors]) - f.write(f"| {cid} | {councilors}\n") \ No newline at end of file + f.write(f"| {cid} | {councilors}\n") diff --git a/scrap/utils/runner.py b/scrap/utils/runner.py index b0fb630..fc0955d 100644 --- a/scrap/utils/runner.py +++ b/scrap/utils/runner.py @@ -108,7 +108,7 @@ def run_single_council(self, n: int) -> ScrapResult: else: if council_args is None: raise ValueError(f"{n}번 의회에 대한 ScrapBasicArgument가 없습니다.") - + if self.is_selenium_basic(n): result = sel_scrap_basic(council_url, n, council_args) else: diff --git a/scrap/utils/spreadsheet.py b/scrap/utils/spreadsheet.py index cb0d348..7ec208d 100644 --- a/scrap/utils/spreadsheet.py +++ b/scrap/utils/spreadsheet.py @@ -11,6 +11,7 @@ from scrap.local_councils.daegu import * from scrap.local_councils.incheon import * from scrap.local_councils.gwangju import * + # from scrap.local_councils.daejeon import * from scrap.local_councils.ulsan import * from scrap.local_councils.gyeonggi import *