Skip to content

Commit f1057b9

Browse files
committed
add fiels
1 parent 6364263 commit f1057b9

File tree

7 files changed

+58
-30
lines changed

7 files changed

+58
-30
lines changed

scrapegraph-py/scrapegraph_py/async_client.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def __init__(
6363
"""Initialize AsyncClient with configurable parameters.
6464
6565
Args:
66-
api_key: API key for authentication. If None, will try to load from environment
66+
api_key: API key for authentication. If None, will try to
67+
load from environment
6768
verify_ssl: Whether to verify SSL certificates
6869
timeout: Request timeout in seconds. None means no timeout (infinite)
6970
max_retries: Maximum number of retry attempts
@@ -83,7 +84,8 @@ def __init__(
8384

8485
validate_api_key(api_key)
8586
logger.debug(
86-
f"🛠️ Configuration: verify_ssl={verify_ssl}, timeout={timeout}, max_retries={max_retries}"
87+
f"🛠️ Configuration: verify_ssl={verify_ssl}, "
88+
f"timeout={timeout}, max_retries={max_retries}"
8789
)
8890
self.api_key = api_key
8991
self.headers = {**DEFAULT_HEADERS, "SGAI-APIKEY": api_key}
@@ -104,7 +106,8 @@ async def _make_request(self, method: str, url: str, **kwargs) -> Any:
104106
for attempt in range(self.max_retries):
105107
try:
106108
logger.info(
107-
f"🚀 Making {method} request to {url} (Attempt {attempt + 1}/{self.max_retries})"
109+
f"🚀 Making {method} request to {url} "
110+
f"(Attempt {attempt + 1}/{self.max_retries})"
108111
)
109112
logger.debug(f"🔍 Request parameters: {kwargs}")
110113

@@ -255,7 +258,8 @@ async def get_credits(self):
255258
f"{API_BASE_URL}/credits",
256259
)
257260
logger.info(
258-
f"✨ Credits info retrieved: {result.get('remaining_credits')} credits remaining"
261+
f"✨ Credits info retrieved: "
262+
f"{result.get('remaining_credits')} credits remaining"
259263
)
260264
return result
261265

@@ -271,8 +275,9 @@ async def searchscraper(
271275
Args:
272276
user_prompt: The search prompt string
273277
num_results: Number of websites to scrape (3-20). Default is 3.
274-
More websites provide better research depth but cost more credits.
275-
Credit calculation: 30 base + 10 per additional website beyond 3.
278+
More websites provide better research depth but cost more
279+
credits. Credit calculation: 30 base + 10 per additional
280+
website beyond 3.
276281
headers: Optional headers to send with the request
277282
output_schema: Optional schema to structure the output
278283
"""
@@ -323,7 +328,8 @@ async def crawl(
323328
batch_size: Optional[int] = None,
324329
sitemap: bool = False,
325330
):
326-
"""Send a crawl request with support for both AI extraction and markdown conversion modes"""
331+
"""Send a crawl request with support for both AI extraction and
332+
markdown conversion modes"""
327333
logger.info("🔍 Starting crawl request")
328334
logger.debug(f"🌐 URL: {url}")
329335
logger.debug(

scrapegraph-py/scrapegraph_py/client.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def __init__(
6464
"""Initialize Client with configurable parameters.
6565
6666
Args:
67-
api_key: API key for authentication. If None, will try to load from environment
67+
api_key: API key for authentication. If None, will try to load
68+
from environment
6869
verify_ssl: Whether to verify SSL certificates
6970
timeout: Request timeout in seconds. None means no timeout (infinite)
7071
max_retries: Maximum number of retry attempts
@@ -84,7 +85,8 @@ def __init__(
8485

8586
validate_api_key(api_key)
8687
logger.debug(
87-
f"🛠️ Configuration: verify_ssl={verify_ssl}, timeout={timeout}, max_retries={max_retries}"
88+
f"🛠️ Configuration: verify_ssl={verify_ssl}, timeout={timeout}, "
89+
f"max_retries={max_retries}"
8890
)
8991

9092
self.api_key = api_key
@@ -260,7 +262,8 @@ def get_credits(self):
260262
f"{API_BASE_URL}/credits",
261263
)
262264
logger.info(
263-
f"✨ Credits info retrieved: {result.get('remaining_credits')} credits remaining"
265+
f"✨ Credits info retrieved: {result.get('remaining_credits')} "
266+
f"credits remaining"
264267
)
265268
return result
266269

@@ -276,8 +279,9 @@ def searchscraper(
276279
Args:
277280
user_prompt: The search prompt string
278281
num_results: Number of websites to scrape (3-20). Default is 3.
279-
More websites provide better research depth but cost more credits.
280-
Credit calculation: 30 base + 10 per additional website beyond 3.
282+
More websites provide better research depth but cost more
283+
credits. Credit calculation: 30 base + 10 per additional
284+
website beyond 3.
281285
headers: Optional headers to send with the request
282286
output_schema: Optional schema to structure the output
283287
"""
@@ -326,7 +330,8 @@ def crawl(
326330
batch_size: Optional[int] = None,
327331
sitemap: bool = False,
328332
):
329-
"""Send a crawl request with support for both AI extraction and markdown conversion modes"""
333+
"""Send a crawl request with support for both AI extraction and
334+
markdown conversion modes"""
330335
logger.info("🔍 Starting crawl request")
331336
logger.debug(f"🌐 URL: {url}")
332337
logger.debug(

scrapegraph-py/scrapegraph_py/models/crawl.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ class CrawlRequest(BaseModel):
1414
)
1515
extraction_mode: bool = Field(
1616
default=True,
17-
description="True for AI extraction mode, False for markdown conversion mode (no AI/LLM processing)",
17+
description="True for AI extraction mode, False for markdown conversion "
18+
"mode (no AI/LLM processing)",
1819
)
1920
prompt: Optional[str] = Field(
2021
default=None,
21-
example="What does the company do? and I need text content from there privacy and terms",
22-
description="The prompt to guide the crawl and extraction (required when extraction_mode=True)",
22+
example="What does the company do? and I need text content from there "
23+
"privacy and terms",
24+
description="The prompt to guide the crawl and extraction (required when "
25+
"extraction_mode=True)",
2326
)
2427
data_schema: Optional[Dict[str, Any]] = Field(
2528
default=None,
26-
description="JSON schema defining the structure of the extracted data (required when extraction_mode=True)",
29+
description="JSON schema defining the structure of the extracted data "
30+
"(required when extraction_mode=True)",
2731
)
2832
cache_website: bool = Field(
2933
default=True, description="Whether to cache the website content"
@@ -74,11 +78,13 @@ def validate_extraction_mode_requirements(self) -> "CrawlRequest":
7478
# Markdown conversion mode - prompt and data_schema should be None
7579
if self.prompt is not None:
7680
raise ValueError(
77-
"Prompt should not be provided when extraction_mode=False (markdown mode)"
81+
"Prompt should not be provided when extraction_mode=False "
82+
"(markdown mode)"
7883
)
7984
if self.data_schema is not None:
8085
raise ValueError(
81-
"Data schema should not be provided when extraction_mode=False (markdown mode)"
86+
"Data schema should not be provided when extraction_mode=False "
87+
"(markdown mode)"
8288
)
8389

8490
return self

scrapegraph-py/scrapegraph_py/models/markdownify.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ class MarkdownifyRequest(BaseModel):
1111
headers: Optional[dict[str, str]] = Field(
1212
None,
1313
example={
14-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
14+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
15+
"AppleWebKit/537.36",
1516
"Cookie": "cookie1=value1; cookie2=value2",
1617
},
17-
description="Optional headers to send with the request, including cookies and user agent",
18+
description="Optional headers to send with the request, including cookies "
19+
"and user agent",
1820
)
1921

2022
@model_validator(mode="after")

scrapegraph-py/scrapegraph_py/models/searchscraper.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ class SearchScraperRequest(BaseModel):
1313
ge=3,
1414
le=20,
1515
example=5,
16-
description="Number of websites to scrape (3-20). Default is 3. More websites provide better research depth but cost more credits.",
16+
description="Number of websites to scrape (3-20). Default is 3. More "
17+
"websites provide better research depth but cost more credits.",
1718
)
1819
headers: Optional[dict[str, str]] = Field(
1920
None,
2021
example={
21-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
22+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
23+
"AppleWebKit/537.36",
2224
"Cookie": "cookie1=value1; cookie2=value2",
2325
},
24-
description="Optional headers to send with the request, including cookies and user agent",
26+
description="Optional headers to send with the request, including cookies "
27+
"and user agent",
2528
)
2629
output_schema: Optional[Type[BaseModel]] = None
2730

scrapegraph-py/scrapegraph_py/models/smartscraper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,30 @@ class SmartScraperRequest(BaseModel):
2323
headers: Optional[dict[str, str]] = Field(
2424
None,
2525
example={
26-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
26+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
27+
"AppleWebKit/537.36",
2728
"Cookie": "cookie1=value1; cookie2=value2",
2829
},
29-
description="Optional headers to send with the request, including cookies and user agent",
30+
description="Optional headers to send with the request, including cookies "
31+
"and user agent",
3032
)
3133
cookies: Optional[Dict[str, str]] = Field(
3234
None,
3335
example={"session_id": "abc123", "user_token": "xyz789"},
34-
description="Dictionary of cookies to send with the request for authentication or session management",
36+
description="Dictionary of cookies to send with the request for "
37+
"authentication or session management",
3538
)
3639
output_schema: Optional[Type[BaseModel]] = None
3740
number_of_scrolls: Optional[conint(ge=0, le=100)] = Field(
3841
default=None,
39-
description="Number of times to scroll the page (0-100). If None, no scrolling will be performed.",
42+
description="Number of times to scroll the page (0-100). If None, no "
43+
"scrolling will be performed.",
4044
example=10,
4145
)
4246
total_pages: Optional[conint(ge=1, le=10)] = Field(
4347
default=None,
44-
description="Number of pages to scrape (1-10). If None, only the first page will be scraped.",
48+
description="Number of pages to scrape (1-10). If None, only the first "
49+
"page will be scraped.",
4550
example=5,
4651
)
4752

scrapegraph-py/scrapegraph_py/utils/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def validate_api_key(api_key: str) -> bool:
1717
UUID(uuid_part)
1818
except ValueError:
1919
raise ValueError(
20-
"Invalid API key format. API key must be 'sgai-' followed by a valid UUID. You can get one at https://dashboard.scrapegraphai.com/"
20+
"Invalid API key format. API key must be 'sgai-' followed by a valid UUID. "
21+
"You can get one at https://dashboard.scrapegraphai.com/"
2122
)
2223
return True
2324

0 commit comments

Comments
 (0)