Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fixed documentation and fetch_text_node
VinciGit00ab71a6bc5ab7
diff --git a/examples/graph_examples/graph_from_text_example.py b/examples/graph_examples/graph_from_text_example.pyindex 80563bd7..2c7027bf 100644--- a/examples/graph_examples/graph_from_text_example.py+++ b/examples/graph_examples/graph_from_text_example.py@@ -6,7 +6,7 @@ import osfrom dotenv import load_dotenvfrom scrapegraphai.models import OpenAIfrom scrapegraphai.graphs import BaseGraph-from scrapegraphai.nodes import TextNode, ParseTextNode, GenerateAnswerNode+from scrapegraphai.nodes import FetchTextNode, ParseTextNode, GenerateAnswerNodeload_dotenv()@@ -25,7 +25,7 @@ with open("text_example.txt", "r", encoding="utf-8") as file:# define the nodes for the graph-fetch_html_node = TextNode("load_html")+fetch_html_node = FetchTextNode("load_html")parse_document_node = ParseTextNode("parse_document")generate_answer_node = GenerateAnswerNode(model, "generate_answer")@@ -45,7 +45,7 @@ graph = BaseGraph(# execute the graphinputs = {"user_input": "Give me the name of all the news",- "url": text}+ "text": text}result = graph.execute(inputs)# get the answer from the resultdiff --git a/scrapegraphai/nodes/__init__.py b/scrapegraphai/nodes/__init__.pyindex 36fb58a9..86f7e841 100644--- a/scrapegraphai/nodes/__init__.py+++ b/scrapegraphai/nodes/__init__.py@@ -9,5 +9,5 @@ from .parse_html_node import ParseHTMLNodefrom .rag_node import RAGNodefrom .text_to_speech_node import TextToSpeechNodefrom .image_to_text_node import ImageToTextNode-from .text_node import TextNode+from .fetch_text_node import FetchTextNodefrom .parse_text_node import ParseTextNodediff --git a/scrapegraphai/nodes/text_node.py b/scrapegraphai/nodes/fetch_text_node.pysimilarity index 88%rename from scrapegraphai/nodes/text_node.pyrename to scrapegraphai/nodes/fetch_text_node.pyindex fb6ee5c6..b13c35bb 100644--- a/scrapegraphai/nodes/text_node.py+++ b/scrapegraphai/nodes/fetch_text_node.py@@ -1,10 +1,10 @@"""-Module for TextNode+Module for FetchTextNode"""from .base_node import BaseNode-class TextNode(BaseNode):+class FetchTextNode(BaseNode):"""A node for loading raw text into the state.@@ -27,7 +27,7 @@ class TextNode(BaseNode):def __init__(self, node_name: str):"""- Initializes the TextNode with a node name.+ Initializes the FetchTextNode with a node name.Args:node_name (str): The unique name for the node.@@ -39,7 +39,7 @@ class TextNode(BaseNode):Loads raw text content into the state.Args:- state (dict): The current state, expected to contain a 'url' key+ state (dict): The current state, expected to contain a 'text' keyindicating the source of the text.Returns:@@ -50,8 +50,8 @@ class TextNode(BaseNode):"""print("---LOADING TEXT CODE---")- if 'url' not in state:+ if 'text' not in state:raise KeyError("The 'url' key is required to load the text.")- state["document"] = state["url"]+ state["document"] = state["text"]return statediff --git a/scrapegraphai/nodes/parse_text_node.py b/scrapegraphai/nodes/parse_text_node.pyindex b94e5287..ee784b29 100644--- a/scrapegraphai/nodes/parse_text_node.py+++ b/scrapegraphai/nodes/parse_text_node.py@@ -42,14 +42,15 @@ class ParseTextNode(BaseNode):Args:state (dict): Expects the following keys:- * 'document': The HTML content to parse.- * 'tags' (optional): A list of HTML tags to target for extraction.+ 'document': The HTML content to parse.+ 'tags' (optional): A list of HTML tags to target for extraction.Returns:dict: Updated state with the following:- * 'parsed_document': The extracted content+ 'parsed_document': The extracted content(or the original document if no tags were provided).- * 'document_chunks': The original document split into chunks (using RecursiveCharacterTextSplitter)+ 'document_chunks': The original document split into chunka+ (using RecursiveCharacterTextSplitter)for larger documents.Raises: