Skip to content

Python scraper based on AI

docs: refactor examples

Marco Perinic11fc288963e
diff --git a/examples/openai/custom_graph_openai.py b/examples/openai/custom_graph_openai.py
index 175c51ab..dab82c1f 100644
--- a/examples/openai/custom_graph_openai.py
+++ b/examples/openai/custom_graph_openai.py
@@ -40,6 +40,7 @@ robot_node = RobotsNode(
fetch_node = FetchNode(
input="url | local_dir",
output=["doc"],
+ node_config={"headless": True, "verbose": True}
)
parse_node = ParseNode(
input="doc",
diff --git a/examples/openai/scrape_plain_text_openai.py b/examples/openai/scrape_plain_text_openai.py
index 78418ca4..5d40a29b 100644
--- a/examples/openai/scrape_plain_text_openai.py
+++ b/examples/openai/scrape_plain_text_openai.py
@@ -52,11 +52,3 @@ print(result)
graph_exec_info = smart_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
-
-# ************************************************
-# Get graph execution info
-# ************************************************
-
-graph_exec_info = smart_scraper_graph.get_execution_info()
-print(prettify_exec_info(graph_exec_info))
diff --git a/examples/openai/script_generator_openai.py b/examples/openai/script_generator_openai.py
index be597d98..e731f852 100644
--- a/examples/openai/script_generator_openai.py
+++ b/examples/openai/script_generator_openai.py
@@ -20,7 +20,7 @@ graph_config = {
"api_key": openai_key,
"model": "gpt-3.5-turbo",
},
- "library": "beautifoulsoup"
+ "library": "beautifulsoup"
}
# ************************************************
diff --git a/examples/openai/xml_scraper_openai.py b/examples/openai/xml_scraper_openai.py
index 32b79981..06600afa 100644
--- a/examples/openai/xml_scraper_openai.py
+++ b/examples/openai/xml_scraper_openai.py
@@ -23,13 +23,14 @@ with open(file_path, 'r', encoding="utf-8") as file:
# Define the configuration for the graph
# ************************************************
-gemini_key = os.getenv("GOOGLE_APIKEY")
+openai_key = os.getenv("OPENAI_APIKEY")
graph_config = {
"llm": {
- "api_key": gemini_key,
+ "api_key": openai_key,
"model": "gpt-3.5-turbo",
},
+ "verbose":False,
}
# ************************************************
diff --git a/scrapegraphai/graphs/script_creator_graph.py b/scrapegraphai/graphs/script_creator_graph.py
index 418ec0e6..20fec447 100644
--- a/scrapegraphai/graphs/script_creator_graph.py
+++ b/scrapegraphai/graphs/script_creator_graph.py
@@ -42,10 +42,12 @@ class ScriptCreatorGraph(AbstractGraph):
"""
def __init__(self, prompt: str, source: str, config: dict):
+
+ self.library = config['library']
+
super().__init__(prompt, config, source)
self.input_key = "url" if source.startswith("http") else "local_dir"
- self.library = config['library']
def _create_graph(self) -> BaseGraph:
"""