File tree Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Smartscraper example on bedrock
3
+ """
4
+ import boto3
5
+
6
+ from scrapegraphai .graphs import SmartScraperGraph
7
+
8
+ # 0a. Initialize session
9
+ # If not required delete it
10
+ session = boto3 .Session (
11
+ aws_access_key_id = "..." ,
12
+ aws_secret_access_key = "..." ,
13
+ aws_session_token = "..." ,
14
+ region_name = "us-east-1"
15
+ )
16
+
17
+ # 0b. Initialize client
18
+ client = session .client ("bedrock-runtime" )
19
+
20
+ # 1. Define graph configuration
21
+ config = {
22
+ "llm" : {
23
+ "client" : client ,
24
+ "model" : "bedrock/anthropic.claude-3-sonnet-20240229-v1:0" ,
25
+ "temperature" : 0.0 ,
26
+ "format" : "json"
27
+ },
28
+ "embeddings" : {
29
+ "client" : client ,
30
+ "model" : "bedrock/cohere.embed-multilingual-v3" ,
31
+ },
32
+ }
33
+
34
+ # 2. Create graph instance
35
+ graph = SmartScraperGraph (
36
+ prompt = "List me all the articles" ,
37
+ source = "https://perinim.github.io/projects" ,
38
+ config = config
39
+ )
40
+
41
+ # 3. Scrape away!
42
+ print (graph .run ())
Original file line number Diff line number Diff line change 9
9
10
10
graph_config = {
11
11
"llm" : {
12
- "model" : "ollama/llama3 " ,
12
+ "model" : "ollama/mistral " ,
13
13
"temperature" : 0 ,
14
14
"format" : "json" , # Ollama needs the format to be specified explicitly
15
15
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
27
27
# ************************************************
28
28
29
29
smart_scraper_graph = SmartScraperGraph (
30
- prompt = "List me all the projects with their description. " ,
30
+ prompt = "List me all the titles " ,
31
31
# also accepts a string with the already downloaded HTML code
32
- source = "https://perinim.github.io/projects " ,
32
+ source = "https://www.wired.com/ " ,
33
33
config = graph_config
34
34
)
35
35
You can’t perform that action at this time.
0 commit comments