Skip to content

Commit 92cabe1

Browse files
committed
add load examples from a yml file
1 parent 9917972 commit 92cabe1

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

examples/extras/example.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"llm": {
3+
"model": "ollama/llama3",
4+
"temperature": 0,
5+
"format": "json",
6+
# "base_url": "http://localhost:11434",
7+
},
8+
"embeddings": {
9+
"model": "ollama/nomic-embed-text",
10+
"temperature": 0,
11+
# "base_url": "http://localhost:11434",
12+
},
13+
"verbose": true,
14+
"headless": false
15+
}

examples/extras/load_yml.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
import yaml
5+
from scrapegraphai.graphs import SmartScraperGraph
6+
from scrapegraphai.utils import prettify_exec_info
7+
8+
# ************************************************
9+
# Define the configuration for the graph
10+
# ************************************************
11+
with open("example.yml", 'r') as file:
12+
graph_config = yaml.safe_load(file)
13+
14+
# ************************************************
15+
# Create the SmartScraperGraph instance and run it
16+
# ************************************************
17+
18+
smart_scraper_graph = SmartScraperGraph(
19+
prompt="List me all the titles",
20+
source="https://sport.sky.it/nba?gr=www",
21+
config=graph_config
22+
)
23+
24+
result = smart_scraper_graph.run()
25+
print(result)
26+
27+
# ************************************************
28+
# Get graph execution info
29+
# ************************************************
30+
31+
graph_exec_info = smart_scraper_graph.get_execution_info()
32+
print(prettify_exec_info(graph_exec_info))

0 commit comments

Comments
 (0)