Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix: deepcopy fail for coping model_instance config
smith pengcd0741847411
diff --git a/scrapegraphai/graphs/csv_scraper_multi_graph.py b/scrapegraphai/graphs/csv_scraper_multi_graph.pyindex 59e84783..67498475 100644--- a/scrapegraphai/graphs/csv_scraper_multi_graph.py+++ b/scrapegraphai/graphs/csv_scraper_multi_graph.py@@ -2,9 +2,10 @@CSVScraperMultiGraph Module"""-from copy import copy, deepcopyfrom typing import List, Optionalfrom pydantic import BaseModel++from .base_graph import BaseGraphfrom .abstract_graph import AbstractGraphfrom .csv_scraper_graph import CSVScraperGraph@@ -12,6 +13,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass CSVScraperMultiGraph(AbstractGraph):"""@@ -46,10 +48,7 @@ class CSVScraperMultiGraph(AbstractGraph):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)super().__init__(prompt, config, source, schema)diff --git a/scrapegraphai/graphs/json_scraper_multi_graph.py b/scrapegraphai/graphs/json_scraper_multi_graph.pyindex 42d2232e..c72d8afd 100644--- a/scrapegraphai/graphs/json_scraper_multi_graph.py+++ b/scrapegraphai/graphs/json_scraper_multi_graph.py@@ -2,9 +2,10 @@JSONScraperMultiGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import List, Optionalfrom pydantic import BaseModel+from .base_graph import BaseGraphfrom .abstract_graph import AbstractGraphfrom .json_scraper_graph import JSONScraperGraph@@ -12,6 +13,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass JSONScraperMultiGraph(AbstractGraph):"""@@ -45,10 +47,7 @@ class JSONScraperMultiGraph(AbstractGraph):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)diff --git a/scrapegraphai/graphs/markdown_scraper_multi_graph.py b/scrapegraphai/graphs/markdown_scraper_multi_graph.pyindex 9796c11a..772eebe6 100644--- a/scrapegraphai/graphs/markdown_scraper_multi_graph.py+++ b/scrapegraphai/graphs/markdown_scraper_multi_graph.py@@ -12,6 +12,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass MDScraperMultiGraph(AbstractGraph):"""@@ -42,11 +43,7 @@ class MDScraperMultiGraph(AbstractGraph):"""def __init__(self, prompt: str, source: List[str], config: dict, schema: Optional[BaseModel] = None):- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)-+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)super().__init__(prompt, config, source, schema)diff --git a/scrapegraphai/graphs/omni_search_graph.py b/scrapegraphai/graphs/omni_search_graph.pyindex b6f6df59..c005dbac 100644--- a/scrapegraphai/graphs/omni_search_graph.py+++ b/scrapegraphai/graphs/omni_search_graph.py@@ -2,7 +2,7 @@OmniSearchGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import Optionalfrom pydantic import BaseModel@@ -15,6 +15,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass OmniSearchGraph(AbstractGraph):@@ -48,10 +49,7 @@ class OmniSearchGraph(AbstractGraph):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)diff --git a/scrapegraphai/graphs/pdf_scraper_multi_graph.py b/scrapegraphai/graphs/pdf_scraper_multi_graph.pyindex a7386267..06da6944 100644--- a/scrapegraphai/graphs/pdf_scraper_multi_graph.py+++ b/scrapegraphai/graphs/pdf_scraper_multi_graph.py@@ -2,7 +2,7 @@PdfScraperMultiGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import List, Optionalfrom pydantic import BaseModelfrom .base_graph import BaseGraph@@ -12,6 +12,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass PdfScraperMultiGraph(AbstractGraph):"""@@ -44,10 +45,7 @@ class PdfScraperMultiGraph(AbstractGraph):def __init__(self, prompt: str, source: List[str],config: dict, schema: Optional[BaseModel] = None):- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)diff --git a/scrapegraphai/graphs/script_creator_multi_graph.py b/scrapegraphai/graphs/script_creator_multi_graph.pyindex 969ba722..b2ea8465 100644--- a/scrapegraphai/graphs/script_creator_multi_graph.py+++ b/scrapegraphai/graphs/script_creator_multi_graph.py@@ -2,7 +2,6 @@ScriptCreatorMultiGraph Module"""-from copy import copy, deepcopyfrom typing import List, Optionalfrom pydantic import BaseModel@@ -15,6 +14,7 @@ from ..nodes import (GraphIteratorNode,MergeGeneratedScriptsNode)+from ..utils.copy import safe_deepcopyclass ScriptCreatorMultiGraph(AbstractGraph):"""@@ -47,10 +47,7 @@ class ScriptCreatorMultiGraph(AbstractGraph):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)super().__init__(prompt, config, source, schema)diff --git a/scrapegraphai/graphs/search_graph.py b/scrapegraphai/graphs/search_graph.pyindex 080aaf19..d27e7186 100644--- a/scrapegraphai/graphs/search_graph.py+++ b/scrapegraphai/graphs/search_graph.py@@ -2,7 +2,7 @@SearchGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import Optional, Listfrom pydantic import BaseModel@@ -15,6 +15,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass SearchGraph(AbstractGraph):"""@@ -47,10 +48,7 @@ class SearchGraph(AbstractGraph):def __init__(self, prompt: str, config: dict, schema: Optional[BaseModel] = None):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)self.considered_urls = [] # New attribute to store URLsdiff --git a/scrapegraphai/graphs/smart_scraper_multi_graph.py b/scrapegraphai/graphs/smart_scraper_multi_graph.pyindex 66d53851..82585cf0 100644--- a/scrapegraphai/graphs/smart_scraper_multi_graph.py+++ b/scrapegraphai/graphs/smart_scraper_multi_graph.py@@ -2,7 +2,7 @@SmartScraperMultiGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import List, Optionalfrom pydantic import BaseModel@@ -14,6 +14,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass SmartScraperMultiGraph(AbstractGraph):"""@@ -48,10 +49,7 @@ class SmartScraperMultiGraph(AbstractGraph):self.max_results = config.get("max_results", 3)- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)diff --git a/scrapegraphai/graphs/xml_scraper_multi_graph.py b/scrapegraphai/graphs/xml_scraper_multi_graph.pyindex 8050d50c..493d12ca 100644--- a/scrapegraphai/graphs/xml_scraper_multi_graph.py+++ b/scrapegraphai/graphs/xml_scraper_multi_graph.py@@ -2,7 +2,7 @@XMLScraperMultiGraph Module"""-from copy import copy, deepcopy+from copy import deepcopyfrom typing import List, Optionalfrom pydantic import BaseModel@@ -14,6 +14,7 @@ from ..nodes import (GraphIteratorNode,MergeAnswersNode)+from ..utils.copy import safe_deepcopyclass XMLScraperMultiGraph(AbstractGraph):"""@@ -46,10 +47,7 @@ class XMLScraperMultiGraph(AbstractGraph):def __init__(self, prompt: str, source: List[str],config: dict, schema: Optional[BaseModel] = None):- if all(isinstance(value, str) for value in config.values()):- self.copy_config = copy(config)- else:- self.copy_config = deepcopy(config)+ self.copy_config = safe_deepcopy(config)self.copy_schema = deepcopy(schema)