Python scraper based on AI
Python ai-crawlerai-scrapingai-searchcrawlerdata-extractionfirecrawl-alternativelarge-language-modelllmmarkdownragscrapingscraping-pythonweb-crawlerweb-crawlersweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
refactoring of the classes of constructors
VinciGit00582c99d8794c
diff --git a/scrapegraphai/nodes/fetch_html_node.py b/scrapegraphai/nodes/fetch_html_node.pyindex 082c6cab..f99bc049 100644--- a/scrapegraphai/nodes/fetch_html_node.py+++ b/scrapegraphai/nodes/fetch_html_node.py@@ -33,9 +33,12 @@ class FetchHTMLNode(BaseNode):to succeed."""- def __init__(self, node_name: str, node_type: str = "node"):+ def __init__(self, node_name: str, node_type: str = "fetch_node"):"""Initializes the FetchHTMLNode with a node name and node type.+ Arguments:+ node_name (str): name of the node+ node_type (str, optional): type of the node"""super().__init__(node_name, node_type)@@ -54,6 +57,7 @@ class FetchHTMLNode(BaseNode):KeyError: If the 'url' key is not found in the state, indicating that thenecessary information to perform the operation is missing."""+ print("---FETCHING HTML CODE---")try:url = state["url"]except KeyError as e:diff --git a/scrapegraphai/nodes/generate_answer_node.py b/scrapegraphai/nodes/generate_answer_node.pyindex 6bb90772..86363c76 100644--- a/scrapegraphai/nodes/generate_answer_node.py+++ b/scrapegraphai/nodes/generate_answer_node.py@@ -32,11 +32,15 @@ class GenerateAnswerNode(BaseNode):updating the state with the generated answer under the 'answer' key."""- def __init__(self, llm, node_name: str = "GenerateAnswerNode"):+ def __init__(self, llm, node_name: str, node_type: str = "GenerateAnswerNode"):"""Initializes the GenerateAnswerNode with a language model client and a node name.+ Args:+ llm (OpenAIImageToText): An instance of the OpenAIImageToText class.+ node_name (str): name of the node+ node_type (str, optional): type of the node"""- super().__init__(node_name, "node")+ super().__init__(node_name, node_type)self.llm = llmdef execute(self, state: dict) -> dict:@@ -58,7 +62,7 @@ class GenerateAnswerNode(BaseNode):that the necessary information for generating an answer is missing."""- print("---GENERATE ANSWER---")+ print("---GENERATING ANSWER---")try:user_input = state["user_input"]document = state["document"]diff --git a/scrapegraphai/nodes/get_probable_tags_node.py b/scrapegraphai/nodes/get_probable_tags_node.pyindex 068e7636..56f67402 100644--- a/scrapegraphai/nodes/get_probable_tags_node.py+++ b/scrapegraphai/nodes/get_probable_tags_node.py@@ -29,11 +29,15 @@ class GetProbableTagsNode(BaseNode):probable HTML tags, updating the state with these tags under the 'tags' key."""- def __init__(self, llm, node_name: str = "GetProbableTagsNode"):+ def __init__(self, llm, node_name: str, node_type: str = "GetPropbableTagsNode"):"""Initializes the GetProbableTagsNode with a language model client and a node name.+ Args:+ llm (OpenAIImageToText): An instance of the OpenAIImageToText class.+ node_name (str): name of the node+ node_type (str, optional): type of the node"""- super().__init__(node_name, "node")+ super().__init__(node_name, node_type)self.llm = llmdef execute(self, state: dict):@@ -54,7 +58,7 @@ class GetProbableTagsNode(BaseNode):necessary information for generating tag predictions is missing."""- print("---GET PROBABLE TAGS---")+ print("---GETTING PROBABLE TAGS---")try:user_input = state["user_input"]url = state["url"]diff --git a/scrapegraphai/nodes/image_to_text_node.py b/scrapegraphai/nodes/image_to_text_node.pyindex 5b859fbc..8c7b8ec0 100644--- a/scrapegraphai/nodes/image_to_text_node.py+++ b/scrapegraphai/nodes/image_to_text_node.py@@ -4,6 +4,7 @@ Module for the ImageToTextNode class.from .base_node import BaseNode+class ImageToTextNode(BaseNode):"""A class representing a node that processes an image and returns the text description.@@ -15,13 +16,14 @@ class ImageToTextNode(BaseNode):execute(state, url): Execute the node's logic and return the updated state."""- def __init__(self, llm, node_name: str = "ParseImageToText"):+ def __init__(self, llm, node_name: str, node_type: str = "ImageToTextNode"):"""Initializes an instance of the ImageToTextNode class.Args:llm (OpenAIImageToText): An instance of the OpenAIImageToText class.- node_name (str, optional): The name of the node. Defaults to "ParseImageToText".+ node_name (str): name of the node+ node_type (str, optional): type of the node"""super().__init__(node_name, "node")self.llm = llmdiff --git a/scrapegraphai/nodes/parse_html_node.py b/scrapegraphai/nodes/parse_html_node.pyindex e3309837..106db34d 100644--- a/scrapegraphai/nodes/parse_html_node.py+++ b/scrapegraphai/nodes/parse_html_node.py@@ -27,11 +27,14 @@ class ParseHTMLNode(BaseNode):the specified tags, if provided, and updates the state with the parsed content."""- def __init__(self, node_name="ParseHTMLNode"):+ def __init__(self, node_name: str, node_type: str = "ParseHTMLNode"):"""Initializes the ParseHTMLNode with a node name.+ Args:+ node_name (str): name of the node+ node_type (str, optional): type of the node"""- super().__init__(node_name, "node")+ super().__init__(node_name, node_type)def execute(self, state):"""@@ -53,7 +56,7 @@ class ParseHTMLNode(BaseNode):information for parsing is missing."""- print("---PARSE HTML DOCUMENT---")+ print("---PARSING HTML DOCUMENT---")try:document = state["document"]except KeyError as e:diff --git a/scrapegraphai/nodes/rag_node.py b/scrapegraphai/nodes/rag_node.pyindex 48cd6fff..603bbc9f 100644--- a/scrapegraphai/nodes/rag_node.py+++ b/scrapegraphai/nodes/rag_node.py@@ -63,7 +63,7 @@ class RAGNode(BaseNode):information for parsing is missing."""- print("---PARSE HTML DOCUMENT---")+ print("---PARSING HTML DOCUMENT---")try:user_input = state["user_input"]document = state["document"]