Skip to content

Python scraper based on AI

add load examples from a yml file

Marco Vinciguerra92cabe1da637
diff --git a/examples/extras/example.yml b/examples/extras/example.yml
new file mode 100644
index 00000000..fd5713c7
--- /dev/null
+++ b/examples/extras/example.yml
@@ -0,0 +1,15 @@
+{
+ "llm": {
+ "model": "ollama/llama3",
+ "temperature": 0,
+ "format": "json",
+ # "base_url": "http://localhost:11434",
+ },
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ # "base_url": "http://localhost:11434",
+ },
+ "verbose": true,
+ "headless": false
+}
\ No newline at end of file
diff --git a/examples/extras/load_yml.py b/examples/extras/load_yml.py
new file mode 100644
index 00000000..974ba4d5
--- /dev/null
+++ b/examples/extras/load_yml.py
@@ -0,0 +1,32 @@
+"""
+Basic example of scraping pipeline using SmartScraper
+"""
+import yaml
+from scrapegraphai.graphs import SmartScraperGraph
+from scrapegraphai.utils import prettify_exec_info
+
+# ************************************************
+# Define the configuration for the graph
+# ************************************************
+with open("example.yml", 'r') as file:
+ graph_config = yaml.safe_load(file)
+
+# ************************************************
+# Create the SmartScraperGraph instance and run it
+# ************************************************
+
+smart_scraper_graph = SmartScraperGraph(
+ prompt="List me all the titles",
+ source="https://sport.sky.it/nba?gr=www",
+ config=graph_config
+)
+
+result = smart_scraper_graph.run()
+print(result)
+
+# ************************************************
+# Get graph execution info
+# ************************************************
+
+graph_exec_info = smart_scraper_graph.get_execution_info()
+print(prettify_exec_info(graph_exec_info))