Skip to content

Commit 9e9c775

Browse files
committed
add examples multi concat
1 parent 77d0fd3 commit 9e9c775

37 files changed

+583
-827
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
5+
import os
6+
import json
7+
from dotenv import load_dotenv
8+
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
9+
10+
load_dotenv()
11+
12+
# ************************************************
13+
# Create the SmartScraperGraph instance and run it
14+
# ************************************************
15+
16+
graph_config = {
17+
"llm": {
18+
"api_key": os.getenv("ANTHROPIC_API_KEY"),
19+
"model": "anthropic/claude-3-haiku-20240307",
20+
},
21+
}
22+
23+
24+
# *******************************************************
25+
# Create the SmartScraperMultiGraph instance and run it
26+
# *******************************************************
27+
28+
multiple_search_graph = SmartScraperMultiConcatGraph(
29+
prompt="Who is Marco Perini?",
30+
source= [
31+
"https://perinim.github.io/",
32+
"https://perinim.github.io/cv/"
33+
],
34+
schema=None,
35+
config=graph_config
36+
)
37+
38+
result = multiple_search_graph.run()
39+
print(json.dumps(result, indent=4))

examples/azure/smart_scraper_multi_azure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
Basic example of scraping pipeline using SmartScraper
33
"""
4-
5-
import os, json
4+
import os
5+
import json
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SmartScraperMultiGraph
88

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
5+
import os
6+
import json
7+
from dotenv import load_dotenv
8+
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
9+
10+
load_dotenv()
11+
12+
# ************************************************
13+
# Define the configuration for the graph
14+
# ************************************************
15+
graph_config = {
16+
"llm": {
17+
"api_key": os.environ["AZURE_OPENAI_KEY"],
18+
"model": "azure_openai/gpt-3.5-turbo",
19+
},
20+
"verbose": True,
21+
"headless": False
22+
}
23+
24+
# *******************************************************
25+
# Create the SmartScraperMultiGraph instance and run it
26+
# *******************************************************
27+
28+
multiple_search_graph = SmartScraperMultiConcatGraph(
29+
prompt="Who is Marco Perini?",
30+
source= [
31+
"https://perinim.github.io/",
32+
"https://perinim.github.io/cv/"
33+
],
34+
schema=None,
35+
config=graph_config
36+
)
37+
38+
result = multiple_search_graph.run()
39+
print(json.dumps(result, indent=4))

examples/bedrock/smart_scraper_multi_bedrock.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
"""
22
Basic example of scraping pipeline using SmartScraper
33
"""
4-
5-
import os, json
6-
from dotenv import load_dotenv
4+
import json
75
from scrapegraphai.graphs import SmartScraperMultiGraph
86

9-
load_dotenv()
107

118
# ************************************************
129
# Define the configuration for the graph
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
import json
5+
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
6+
7+
# ************************************************
8+
# Define the configuration for the graph
9+
# ************************************************
10+
11+
graph_config = {
12+
"llm": {
13+
"client": "client_name",
14+
"model": "bedrock/anthropic.claude-3-sonnet-20240229-v1:0",
15+
"temperature": 0.0
16+
}
17+
}
18+
19+
20+
# *******************************************************
21+
# Create the SmartScraperMultiGraph instance and run it
22+
# *******************************************************
23+
24+
multiple_search_graph = SmartScraperMultiConcatGraph(
25+
prompt="Who is Marco Perini?",
26+
source= [
27+
"https://perinim.github.io/",
28+
"https://perinim.github.io/cv/"
29+
],
30+
schema=None,
31+
config=graph_config
32+
)
33+
34+
result = multiple_search_graph.run()
35+
print(json.dumps(result, indent=4))

examples/deepseek/smart_scraper_deepseek.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
load_dotenv()
1111

12-
1312
# ************************************************
1413
# Define the configuration for the graph
1514
# ************************************************
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
5+
import os
6+
import json
7+
from dotenv import load_dotenv
8+
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
9+
10+
load_dotenv()
11+
12+
# ************************************************
13+
# Define the configuration for the graph
14+
# ************************************************
15+
16+
deepseek_key = os.getenv("DEEPSEEK_APIKEY")
17+
18+
graph_config = {
19+
"llm": {
20+
"model": "deepseek/deepseek-chat",
21+
"api_key": deepseek_key,
22+
},
23+
"verbose": True,
24+
}
25+
26+
27+
# *******************************************************
28+
# Create the SmartScraperMultiGraph instance and run it
29+
# *******************************************************
30+
31+
multiple_search_graph = SmartScraperMultiConcatGraph(
32+
prompt="Who is Marco Perini?",
33+
source= [
34+
"https://perinim.github.io/",
35+
"https://perinim.github.io/cv/"
36+
],
37+
schema=None,
38+
config=graph_config
39+
)
40+
41+
result = multiple_search_graph.run()
42+
print(json.dumps(result, indent=4))

examples/ernie/smart_scraper_ernie.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
Basic example of scraping pipeline using SmartScraper
33
"""
44

5-
import os
6-
from dotenv import load_dotenv
75
from scrapegraphai.graphs import SmartScraperGraph
86
from scrapegraphai.utils import prettify_exec_info
97

10-
load_dotenv()
11-
12-
138
# ************************************************
149
# Define the configuration for the graph
1510
# ************************************************
1611

17-
graph_config = {
12+
graph_config = {
1813
"llm": {
1914
"model": "ernie/ernie-bot-turbo",
2015
"ernie_client_id": "<ernie_client_id>",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
import json
5+
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
6+
7+
# ************************************************
8+
# Define the configuration for the graph
9+
# ************************************************
10+
graph_config = {
11+
"llm": {
12+
"model": "ernie/ernie-bot-turbo",
13+
"ernie_client_id": "<ernie_client_id>",
14+
"ernie_client_secret": "<ernie_client_secret>",
15+
"temperature": 0.1
16+
},
17+
"library": "beautifulsoup"
18+
}
19+
20+
# *******************************************************
21+
# Create the SmartScraperMultiGraph instance and run it
22+
# *******************************************************
23+
24+
multiple_search_graph = SmartScraperMultiConcatGraph(
25+
prompt="Who is Marco Perini?",
26+
source= [
27+
"https://perinim.github.io/",
28+
"https://perinim.github.io/cv/"
29+
],
30+
schema=None,
31+
config=graph_config
32+
)
33+
34+
result = multiple_search_graph.run()
35+
print(json.dumps(result, indent=4))

examples/fireworks/smart_scraper_fireworks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
Basic example of scraping pipeline using SmartScraper
33
"""
4-
5-
import os, json
4+
import os
5+
import json
66
from dotenv import load_dotenv
77
from scrapegraphai.graphs import SmartScraperGraph
88
from scrapegraphai.utils import prettify_exec_info

0 commit comments

Comments
 (0)