Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
change GenerateScraperNode to only use first chunk
Tom Robinson3d265a863173
diff --git a/scrapegraphai/graphs/script_creator_graph.py b/scrapegraphai/graphs/script_creator_graph.pyindex 291ac2ad..73c709eb 100644--- a/scrapegraphai/graphs/script_creator_graph.py+++ b/scrapegraphai/graphs/script_creator_graph.py@@ -78,7 +78,7 @@ class ScriptCreatorGraph(AbstractGraph):})generate_scraper_node = GenerateScraperNode(- input="user_prompt & (doc)",+ input="user_prompt & (parsed_doc)",output=["answer"],node_config={"llm_model": self.llm_model,diff --git a/scrapegraphai/nodes/generate_scraper_node.py b/scrapegraphai/nodes/generate_scraper_node.pyindex a7c5e5bb..ce6259df 100644--- a/scrapegraphai/nodes/generate_scraper_node.py+++ b/scrapegraphai/nodes/generate_scraper_node.py@@ -102,9 +102,19 @@ class GenerateScraperNode(BaseNode):TEMPLATE_NO_CHUNKS += self.additional_infoif len(doc) > 1:- raise NotImplementedError(- "Currently GenerateScraperNode cannot handle more than 1 context chunks"- )+ # Short term partial fix for issue #543 (Context length exceeded)+ # If there are more than one chunks returned by ParseNode we just use the first one+ # on the basis that the structure of the remainder of the HTML page is probably+ # very similar to the first chunk therefore the generated script should still work.+ # The better fix is to generate multiple scripts then use the LLM to merge them.++ #raise NotImplementedError(+ # "Currently GenerateScraperNode cannot handle more than 1 context chunks"+ #)+ self.logger.warn(f"Warning: {self.node_name} Node provided with {len(doc)} chunks but can only "+ "support 1, ignoring remaining chunks")+ doc = [doc[0]]+ template = TEMPLATE_NO_CHUNKSelse:template = TEMPLATE_NO_CHUNKS