Skip to content

Python scraper based on AI

update project requirement and add example

ekinsenlereaa83edc04b8
diff --git a/examples/extras/cond_smartscraper_usage.py b/examples/extras/cond_smartscraper_usage.py
new file mode 100644
index 00000000..54c40712
--- /dev/null
+++ b/examples/extras/cond_smartscraper_usage.py
@@ -0,0 +1,38 @@
+"""
+Basic example of scraping pipeline using SmartScraperMultiConcatGraph with Groq
+"""
+
+import os
+import json
+from dotenv import load_dotenv
+from scrapegraphai.graphs import SmartScraperGraph
+
+load_dotenv()
+
+# ************************************************
+# Define the configuration for the graph
+# ************************************************
+
+graph_config = {
+ "llm": {
+ "api_key": os.getenv("GROQ_APIKEY"),
+ "model": "groq/gemma-7b-it",
+ },
+ "verbose": True,
+ "headless": True,
+ "reattempt": True #Setting this to True will allow the graph to reattempt the scraping process
+}
+
+# *******************************************************
+# Create the SmartScraperMultiCondGraph instance and run it
+# *******************************************************
+
+multiple_search_graph = SmartScraperGraph(
+ prompt="Who is Marco Perini?",
+ source="https://perinim.github.io/",
+ schema=None,
+ config=graph_config
+)
+
+result = multiple_search_graph.run()
+print(json.dumps(result, indent=4))
diff --git a/pyproject.toml b/pyproject.toml
index 6bade627..7a374c97 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -38,7 +38,8 @@ dependencies = [
"async-timeout>=4.0.3",
"transformers>=4.44.2",
"googlesearch-python>=1.2.5",
- "simpleeval>=1.0.0"
+ "simpleeval>=1.0.0",
+ "async_timeout>=4.0.3"
]
license = "MIT"