From 75e974fbd42370122626d53d92886747862b058c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Mart=C3=ADn=20N=C3=BA=C3=B1ez?= <83213317+P-ict0@users.noreply.github.com> Date: Sun, 23 Jun 2024 17:08:52 +0200 Subject: [PATCH] Avoid creating a new JSON file for each loop when -p is not specified --- pyproject.toml | 2 +- src/web_scraper/utils/json.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 322093a..0c57ba8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "dynamic-scraper" -version = "1.0.4" +version = "1.0.5" description = "Dynamic web scraper specifically designed for websites that dynamically load elements (such as AngularJS). It runs at specified time intervals and notifies you about specific updates on the site." readme = "README.md" requires-python = ">=3.10" diff --git a/src/web_scraper/utils/json.py b/src/web_scraper/utils/json.py index ff4e401..bb76fee 100644 --- a/src/web_scraper/utils/json.py +++ b/src/web_scraper/utils/json.py @@ -88,6 +88,10 @@ def ensure_json(self) -> None: self.logger.debug(f"(JSON) Removing existing JSON file: {self.path}") os.remove(self.path) self.create_empty_json() + self.use_previous = True + self.logger.debug( + f"(JSON) Set project to use the new JSON file: {self.path}" + ) else: self.logger.debug(f"(JSON) JSON file doesnt exist, creating: {self.path}") self.create_empty_json()