Skip to content

Commit d29f747

Browse files
committed
Update script_generator_openai.py
1 parent dbec550 commit d29f747

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""
2-
Basic example of scraping pipeline using ScriptCreatorGraph
2+
Basic example of scraping pipeline using SmartScraper
33
"""
44

55
import os
6+
import json
67
from dotenv import load_dotenv
7-
from scrapegraphai.graphs import ScriptCreatorGraph
8+
from scrapegraphai.graphs import SmartScraperGraph
89
from scrapegraphai.utils import prettify_exec_info
910

1011
load_dotenv()
@@ -13,34 +14,32 @@
1314
# Define the configuration for the graph
1415
# ************************************************
1516

16-
openai_key = os.getenv("OPENAI_APIKEY")
1717

1818
graph_config = {
1919
"llm": {
20-
"api_key": openai_key,
21-
"model": "openai/gpt-4o",
20+
"api_key": os.getenv("OPENAI_API_KEY"),
21+
"model": "gpt-4o",
2222
},
23-
"library": "beautifulsoup"
23+
"verbose": True,
24+
"headless": False,
2425
}
2526

2627
# ************************************************
27-
# Create the ScriptCreatorGraph instance and run it
28+
# Create the SmartScraperGraph instance and run it
2829
# ************************************************
2930

30-
script_creator_graph = ScriptCreatorGraph(
31-
prompt="List me all the projects with their description.",
32-
# also accepts a string with the already downloaded HTML code
33-
source="https://perinim.github.io/projects",
31+
smart_scraper_graph = SmartScraperGraph(
32+
prompt="List me what does the company do, the name and a contact email.",
33+
source="https://scrapegraphai.com/",
3434
config=graph_config
3535
)
3636

37-
result = script_creator_graph.run()
38-
print(result)
37+
result = smart_scraper_graph.run()
38+
print(json.dumps(result, indent=4))
3939

4040
# ************************************************
4141
# Get graph execution info
4242
# ************************************************
4343

44-
graph_exec_info = script_creator_graph.get_execution_info()
44+
graph_exec_info = smart_scraper_graph.get_execution_info()
4545
print(prettify_exec_info(graph_exec_info))
46-

0 commit comments

Comments
 (0)