File tree Expand file tree Collapse file tree 3 files changed +100
-68
lines changed Expand file tree Collapse file tree 3 files changed +100
-68
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ dependencies = [
45
45
" googlesearch-python>=1.2.5" ,
46
46
" simpleeval>=1.0.0" ,
47
47
" async_timeout>=4.0.3" ,
48
- " scrapegraph-py>=0.0.4 "
48
+ " scrapegraph-py>=1.7.0 "
49
49
]
50
50
51
51
license = " MIT"
Original file line number Diff line number Diff line change 4
4
5
5
from typing import Optional
6
6
from pydantic import BaseModel
7
+ from scrapegraph_py import Client
8
+ from scrapegraph_py .logger import sgai_logger
7
9
from .base_graph import BaseGraph
8
10
from .abstract_graph import AbstractGraph
9
11
from ..nodes import (
14
16
ConditionalNode ,
15
17
)
16
18
from ..prompts import REGEN_ADDITIONAL_INFO
17
- from scrapegraph_py import SyncClient
18
19
19
20
class SmartScraperGraph (AbstractGraph ):
20
21
"""
@@ -65,12 +66,23 @@ def _create_graph(self) -> BaseGraph:
65
66
"""
66
67
if self .llm_model == "scrapegraphai/smart-scraper" :
67
68
68
- sgai_client = SyncClient ( api_key = self . config . get ( "api_key" ) )
69
+ sgai_logger . set_logging ( level = "INFO" )
69
70
71
+ # Initialize the client with explicit API key
72
+ sgai_client = Client (api_key = self .config .get ("api_key" ))
73
+
74
+ # SmartScraper request
70
75
response = sgai_client .smartscraper (
71
76
website_url = self .source ,
72
- user_prompt = self .prompt
77
+ user_prompt = self .prompt ,
73
78
)
79
+
80
+ # Print the response
81
+ print (f"Request ID: { response ['request_id' ]} " )
82
+ print (f"Result: { response ['result' ]} " )
83
+
84
+ sgai_client .close ()
85
+
74
86
return response
75
87
76
88
fetch_node = FetchNode (
You can’t perform that action at this time.
0 commit comments