Skip to content

Commit e16e94b

Browse files
committed
fix: client
1 parent 5aaa440 commit e16e94b

File tree

3 files changed

+100
-68
lines changed

3 files changed

+100
-68
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies = [
4545
"googlesearch-python>=1.2.5",
4646
"simpleeval>=1.0.0",
4747
"async_timeout>=4.0.3",
48-
"scrapegraph-py>=0.0.4"
48+
"scrapegraph-py>=1.7.0"
4949
]
5050

5151
license = "MIT"

scrapegraphai/graphs/smart_scraper_graph.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7+
from scrapegraph_py import Client
8+
from scrapegraph_py.logger import sgai_logger
79
from .base_graph import BaseGraph
810
from .abstract_graph import AbstractGraph
911
from ..nodes import (
@@ -14,7 +16,6 @@
1416
ConditionalNode,
1517
)
1618
from ..prompts import REGEN_ADDITIONAL_INFO
17-
from scrapegraph_py import SyncClient
1819

1920
class SmartScraperGraph(AbstractGraph):
2021
"""
@@ -65,12 +66,23 @@ def _create_graph(self) -> BaseGraph:
6566
"""
6667
if self.llm_model == "scrapegraphai/smart-scraper":
6768

68-
sgai_client = SyncClient(api_key=self.config.get("api_key"))
69+
sgai_logger.set_logging(level="INFO")
6970

71+
# Initialize the client with explicit API key
72+
sgai_client = Client(api_key=self.config.get("api_key"))
73+
74+
# SmartScraper request
7075
response = sgai_client.smartscraper(
7176
website_url=self.source,
72-
user_prompt=self.prompt
77+
user_prompt=self.prompt,
7378
)
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+
7486
return response
7587

7688
fetch_node = FetchNode(

0 commit comments

Comments
 (0)