Skip to content

Python scraper based on AI

refatoring

Marco Vinciguerraa7db47ecadda
diff --git a/scrapegraphai/graphs/script_creator_multi_graph.py b/scrapegraphai/graphs/script_creator_multi_graph.py
index a415a82c..0bafd561 100644
--- a/scrapegraphai/graphs/script_creator_multi_graph.py
+++ b/scrapegraphai/graphs/script_creator_multi_graph.py
@@ -113,4 +113,4 @@ class ScriptCreatorMultiGraph(AbstractGraph):
"""
inputs = {"user_prompt": self.prompt, "urls": self.source}
self.final_state, self.execution_info = self.graph.execute(inputs)
- return self.final_state.get("merged_script", "Failed to generate the script.")
\ No newline at end of file
+ return self.final_state.get("merged_script", "Failed to generate the script.")
diff --git a/scrapegraphai/graphs/search_link_graph.py b/scrapegraphai/graphs/search_link_graph.py
index 2e23357c..c9521497 100644
--- a/scrapegraphai/graphs/search_link_graph.py
+++ b/scrapegraphai/graphs/search_link_graph.py
@@ -101,4 +101,4 @@ class SearchLinkGraph(AbstractGraph):
inputs = {"user_prompt": self.prompt, self.input_key: self.source}
self.final_state, self.execution_info = self.graph.execute(inputs)
- return self.final_state.get("parsed_doc", "No answer found.")
\ No newline at end of file
+ return self.final_state.get("parsed_doc", "No answer found.")
diff --git a/scrapegraphai/nodes/conditional_node.py b/scrapegraphai/nodes/conditional_node.py
index 0ce424b1..0bf84766 100644
--- a/scrapegraphai/nodes/conditional_node.py
+++ b/scrapegraphai/nodes/conditional_node.py
@@ -1,10 +1,9 @@
"""
Module for implementing the conditional node
"""
-
+from typing import Optional, List
from .base_node import BaseNode
-
class ConditionalNode(BaseNode):
"""
A node that determines the next step in the graph's execution flow based on
@@ -29,7 +28,12 @@ class ConditionalNode(BaseNode):
"""
- def __init__(self, key_name: str, node_name="ConditionalNode"):
+ def __init__(self,
+ input: str,
+ output: List[str],
+ node_config: Optional[dict] = None,
+ node_name: str = "GenerateAnswerCSV",
+ ):
"""
Initializes the node with the key to check and the next node names based on the condition.
@@ -37,8 +41,8 @@ class ConditionalNode(BaseNode):
key_name (str): The name of the key to check in the state.
"""
- super().__init__(node_name, "conditional_node")
- self.key_name = key_name
+ super().__init__(node_name, "node", input, output, 2, node_config)
+
def execute(self, state: dict) -> dict:
"""
diff --git a/scrapegraphai/nodes/generate_answer_csv_node.py b/scrapegraphai/nodes/generate_answer_csv_node.py
index a91dae3f..b8458d9d 100644
--- a/scrapegraphai/nodes/generate_answer_csv_node.py
+++ b/scrapegraphai/nodes/generate_answer_csv_node.py
@@ -58,7 +58,7 @@ class GenerateAnswerCSVNode(BaseNode):
self.verbose = (
False if node_config is None else node_config.get("verbose", False)
)
-
+
self.additional_info = node_config.get("additional_info")
def execute(self, state):