Skip to content

Commit 6ba97bb

Browse files
authored
Merge pull request #76 from ScrapeGraphAI/feat/add-geotargeting-searchscraper
feat: add location_geo_code parameter to SearchScraper
2 parents 81989f2 + b9c5707 commit 6ba97bb

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

scrapegraph-py/scrapegraph_py/async_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,7 @@ async def searchscraper(
782782
output_schema: Optional[BaseModel] = None,
783783
extraction_mode: bool = True,
784784
stealth: bool = False,
785+
location_geo_code: Optional[str] = None,
785786
return_toon: bool = False,
786787
):
787788
"""Send a searchscraper request
@@ -797,6 +798,7 @@ async def searchscraper(
797798
extraction_mode: Whether to use AI extraction (True) or markdown conversion (False).
798799
AI extraction costs 10 credits per page, markdown conversion costs 2 credits per page.
799800
stealth: Enable stealth mode to avoid bot detection
801+
location_geo_code: Optional geo code of the location to search in (e.g., "us")
800802
return_toon: If True, return response in TOON format (reduces token usage by 30-60%)
801803
"""
802804
logger.info("🔍 Starting searchscraper request")
@@ -807,6 +809,8 @@ async def searchscraper(
807809
logger.debug("🔧 Using custom headers")
808810
if stealth:
809811
logger.debug("🥷 Stealth mode enabled")
812+
if location_geo_code:
813+
logger.debug(f"🌍 Location geo code: {location_geo_code}")
810814
if return_toon:
811815
logger.debug("🎨 TOON format output enabled")
812816

@@ -817,6 +821,7 @@ async def searchscraper(
817821
output_schema=output_schema,
818822
extraction_mode=extraction_mode,
819823
stealth=stealth,
824+
location_geo_code=location_geo_code,
820825
)
821826
logger.debug("✅ Request validation passed")
822827

scrapegraph-py/scrapegraph_py/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ def searchscraper(
792792
extraction_mode: bool = True,
793793
mock: bool=False,
794794
stealth: bool=False,
795+
location_geo_code: Optional[str] = None,
795796
return_toon: bool = False,
796797
):
797798
"""Send a searchscraper request
@@ -808,6 +809,7 @@ def searchscraper(
808809
AI extraction costs 10 credits per page, markdown conversion costs 2 credits per page.
809810
mock: Enable mock mode for testing
810811
stealth: Enable stealth mode to avoid bot detection
812+
location_geo_code: Optional geo code of the location to search in (e.g., "us")
811813
return_toon: If True, return response in TOON format (reduces token usage by 30-60%)
812814
"""
813815
logger.info("🔍 Starting searchscraper request")
@@ -818,6 +820,8 @@ def searchscraper(
818820
logger.debug("🔧 Using custom headers")
819821
if stealth:
820822
logger.debug("🥷 Stealth mode enabled")
823+
if location_geo_code:
824+
logger.debug(f"🌍 Location geo code: {location_geo_code}")
821825
if return_toon:
822826
logger.debug("🎨 TOON format output enabled")
823827

@@ -828,7 +832,8 @@ def searchscraper(
828832
output_schema=output_schema,
829833
extraction_mode=extraction_mode,
830834
mock=mock,
831-
stealth=stealth
835+
stealth=stealth,
836+
location_geo_code=location_geo_code,
832837
)
833838
logger.debug("✅ Request validation passed")
834839

scrapegraph-py/scrapegraph_py/models/searchscraper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SearchScraperRequest(BaseModel):
3333
extraction_mode: Use AI extraction (True) or markdown (False)
3434
mock: Whether to use mock mode for testing
3535
render_heavy_js: Whether to render heavy JavaScript
36+
location_geo_code: Optional geo code for location-based search (e.g., "us")
3637
3738
Example:
3839
>>> request = SearchScraperRequest(
@@ -68,6 +69,11 @@ class SearchScraperRequest(BaseModel):
6869
mock: bool = Field(default=False, description="Whether to use mock mode for the request")
6970
render_heavy_js: bool = Field(default=False, description="Whether to render heavy JavaScript on the page")
7071
stealth: bool = Field(default=False, description="Enable stealth mode to avoid bot detection")
72+
location_geo_code: Optional[str] = Field(
73+
None,
74+
description="The geo code of the location to search in",
75+
example="us",
76+
)
7177

7278
@model_validator(mode="after")
7379
def validate_user_prompt(self) -> "SearchScraperRequest":

0 commit comments

Comments
 (0)