1- """
1+ """
22Basic example of scraping pipeline using SmartScraper with schema
33"""
4+
45import json
5- from typing import List
6+
67from pydantic import BaseModel , Field
8+
79from scrapegraphai .graphs import SmartScraperGraph
810from scrapegraphai .utils import prettify_exec_info
911
12+
1013# ************************************************
1114# Define the configuration for the graph
1215# ************************************************
1316class Project (BaseModel ):
1417 title : str = Field (description = "The title of the project" )
1518 description : str = Field (description = "The description of the project" )
1619
20+
1721class Projects (BaseModel ):
18- projects : List [Project ]
22+ projects : list [Project ]
23+
1924
2025graph_config = {
21- "llm" : {
22- "model" : "ollama/llama3.1" ,
23- "temperature" : 0 ,
24- "format" : "json" , # Ollama needs the format to be specified explicitly
25- # "base_url": "http://localhost:11434", # set ollama URL arbitrarily
26- },
26+ "llm" : {"model" : "ollama/llama3.2" , "temperature" : 0 , "model_tokens" : 4096 },
2727 "verbose" : True ,
28- "headless" : False
28+ "headless" : False ,
2929}
3030
3131# ************************************************
@@ -36,8 +36,15 @@ class Projects(BaseModel):
3636 prompt = "List me all the projects with their description" ,
3737 source = "https://perinim.github.io/projects/" ,
3838 schema = Projects ,
39- config = graph_config
39+ config = graph_config ,
4040)
4141
4242result = smart_scraper_graph .run ()
4343print (json .dumps (result , indent = 4 ))
44+
45+ # ************************************************
46+ # Get graph execution info
47+ # ************************************************
48+
49+ graph_exec_info = smart_scraper_graph .get_execution_info ()
50+ print (prettify_exec_info (graph_exec_info ))
0 commit comments