Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.84.0

- Search and Light accept `defer_links=True` to skip inline organic URL lookups. Use `resolve()` or `resolve_all()` when destinations are needed.

## [0.83.1] - 2026-11-26

### Changed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "scrapebadger"
version = "0.83.1"
version = "0.84.0"
description = "Official Python SDK for ScrapeBadger - Async web scraping APIs for Twitter and more"
readme = "README.md"
license = { text = "MIT" }
Expand Down
2 changes: 1 addition & 1 deletion src/scrapebadger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ async def main():
ZestimateHistoryPoint as ZillowZestimateHistoryPoint,
)

__version__ = "0.83.1"
__version__ = "0.84.0"

__all__ = [
# TikTok core models
Expand Down
2 changes: 1 addition & 1 deletion src/scrapebadger/_internal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
T = TypeVar("T")

# User agent for SDK requests
SDK_VERSION = "0.83.1"
SDK_VERSION = "0.84.0"
USER_AGENT = f"scrapebadger-python/{SDK_VERSION}"


Expand Down
14 changes: 14 additions & 0 deletions src/scrapebadger/google/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ async def search(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["html"],
) -> str: ...

Expand Down Expand Up @@ -142,6 +143,7 @@ async def search(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json"] = "json",
) -> dict[str, Any]: ...

Expand Down Expand Up @@ -196,6 +198,7 @@ async def search(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json", "html"],
) -> dict[str, Any] | str: ...

Expand Down Expand Up @@ -249,6 +252,7 @@ async def search(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json", "html"] = "json",
) -> dict[str, Any] | str:
"""Search Google and get a structured SERP response.
Expand Down Expand Up @@ -278,6 +282,7 @@ async def search(
sourceid: Google source identifier. Defaults to chrome; an empty string omits it.
ie: Google input encoding hint. Defaults to UTF-8; an empty string omits it.
user_agent: Custom User-Agent override.
defer_links: Skip inline URL lookups and return link tokens for resolve().
output: json returns structured results; html returns the raw page.
q: Search query (supports Google operators like `site:`, `intitle:`).
gl: Country code (default "us").
Expand Down Expand Up @@ -427,6 +432,8 @@ async def search(
params["expand_related_questions"] = expand_related_questions
if mode != "full":
params["mode"] = mode
if defer_links:
params["defer_links"] = True
if output == "html":
body, _, _ = await self._client.get_raw("/v1/google/search", params=params)
return body.decode("utf-8")
Expand Down Expand Up @@ -480,6 +487,7 @@ async def light(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["html"],
) -> str: ...

Expand Down Expand Up @@ -531,6 +539,7 @@ async def light(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json"] = "json",
) -> dict[str, Any]: ...

Expand Down Expand Up @@ -582,6 +591,7 @@ async def light(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json", "html"],
) -> dict[str, Any] | str: ...

Expand Down Expand Up @@ -632,6 +642,7 @@ async def light(
sourceid: str | None = None,
ie: str | None = None,
user_agent: str | None = None,
defer_links: bool = False,
output: Literal["json", "html"] = "json",
) -> dict[str, Any] | str:
"""Google Light Search — organic results + related searches only.
Expand Down Expand Up @@ -670,6 +681,7 @@ async def light(
sourceid: Google source identifier. Defaults to chrome; an empty string omits it.
ie: Google input encoding hint. Defaults to UTF-8; an empty string omits it.
user_agent: Custom User-Agent override.
defer_links: Skip inline URL lookups and return link tokens for resolve().
output: json returns structured results; html returns the raw page.
q: Search query (supports Google operators like `site:`).
gl: Country code (default "us").
Expand Down Expand Up @@ -749,6 +761,8 @@ async def light(
"ibp": ibp,
"uds": uds,
}
if defer_links:
params["defer_links"] = True
if output == "html":
body, _, _ = await self._client.get_raw("/v1/google/light/search", params=params)
return body.decode("utf-8")
Expand Down
19 changes: 19 additions & 0 deletions tests/test_google_deferred_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from unittest.mock import AsyncMock

import pytest

from scrapebadger.google.search import SearchClient


@pytest.mark.asyncio
@pytest.mark.parametrize(
"method,path", [("search", "/v1/google/search"), ("light", "/v1/google/light/search")]
)
async def test_deferred_links_is_opt_in_and_forwarded(method, path):
base = AsyncMock()
client = SearchClient(base)
await getattr(client, method)("cats")
assert "defer_links" not in base.get.call_args.kwargs["params"]
await getattr(client, method)("cats", defer_links=True)
assert base.get.call_args.args[0] == path
assert base.get.call_args.kwargs["params"]["defer_links"] is True
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading