Skip to content

Python scraper based on AI

add example

Marco Vinciguerraf51b15572dfb
diff --git a/examples/local_models/smart_scraper_multi_ollama.py b/examples/local_models/smart_scraper_multi_ollama.py
new file mode 100644
index 00000000..c9d49793
--- /dev/null
+++ b/examples/local_models/smart_scraper_multi_ollama.py
@@ -0,0 +1,39 @@
+"""
+Basic example of scraping pipeline using SmartScraper
+"""
+
+import json
+from scrapegraphai.graphs import SmartScraperMultiGraph
+
+# ************************************************
+# Define the configuration for the graph
+# ************************************************
+graph_config = {
+ "llm": {
+ "model": "ollama/llama3.1",
+ "temperature": 0,
+ "format": "json", # Ollama needs the format to be specified explicitly
+ # "base_url": "http://localhost:11434", # set ollama URL arbitrarily
+ },
+
+ "verbose": True,
+ "headless": False
+}
+
+
+# *******************************************************
+# Create the SmartScraperMultiGraph instance and run it
+# *******************************************************
+
+multiple_search_graph = SmartScraperMultiGraph(
+ prompt="Who is Marco Perini?",
+ source= [
+ "https://perinim.github.io/",
+ "https://perinim.github.io/cv/"
+ ],
+ schema=None,
+ config=graph_config
+)
+
+result = multiple_search_graph.run()
+print(json.dumps(result, indent=4))
diff --git a/examples/local_models/smart_scraper_schema_ollama.py b/examples/local_models/smart_scraper_schema_ollama.py
index a732aa8d..5f15b080 100644
--- a/examples/local_models/smart_scraper_schema_ollama.py
+++ b/examples/local_models/smart_scraper_schema_ollama.py
@@ -24,7 +24,7 @@ graph_config = {
"format": "json", # Ollama needs the format to be specified explicitly
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
},
-
+
"verbose": True,
"headless": False
}