Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.87.0] - 2026-12-01

### Removed
- **Removed `google.shopping.product()` and `google.shopping.click()`: the endpoints were retired; use `google.shopping.offers()` / `google.products.detail()`.** `GET /v1/google/shopping/product` and `GET /v1/google/shopping/product/click` answer 404, so both methods could only fail. Seller offers for a product come from `google.shopping.offers(barcode=... | catalog_id=...)`; full product detail with merchant offers comes from `google.products.detail(gpcid, q=..., include_offers=True)`. Shopping search tiles carry no `click_link` field. (SCR-764)

## [0.86.0] - 2026-12-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The official Python SDK for [ScrapeBadger](https://scrapebadger.com) - async web
- **Resilient retries** - Exponential backoff on transient errors
- **Async requests and webhooks** - Submit any slow call, poll or `wait` for it, or take a signed webhook; idempotency keys make re-submits safe
- **37+ Twitter endpoints** - Tweets, users, lists, communities, trends, geo, real-time streams
- **20 Google product APIs** - Search (with optional deferred AI Overview follow-up and free result link resolution), Maps, News, Hotels, Trends (incl. topic autocomplete), Jobs, Shopping (+ merchant URL enrichment), Patents, Scholar (search + profiles + author + author citation + cite formats), Images, Videos, Finance, AI Mode, Lens, **Local Pack**, **Shorts**, **Flights**, Products, **Ads Transparency Center**
- **20 Google product APIs** - Search (with optional deferred AI Overview follow-up and free result link resolution), Maps, News, Hotels, Trends (incl. topic autocomplete), Jobs, Shopping (search + seller offers), Patents, Scholar (search + profiles + author + author citation + cite formats), Images, Videos, Finance, AI Mode, Lens, **Local Pack**, **Shorts**, **Flights**, Products, **Ads Transparency Center**
- **Vinted scraping** - Search items, item details, user profiles, brands, colors, markets
- **Reddit scraping** - Search posts/subreddits/users/domains, subreddit posts, post comments, user profiles, trophies, wiki pages, moderators
- **Web scraping** - Anti-bot bypass, JS rendering, screenshots, and selector/AI data extraction
Expand Down
37 changes: 9 additions & 28 deletions docs/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async with ScrapeBadger(api_key="your-key") as client:
print(f"{job['title']} @ {job['company_name']} — {job['location']}")
```

### Shopping (Search + Product Detail + Merchant URL Enrichment)
### Shopping (Search + Seller Offers + Product Detail)

```python
async with ScrapeBadger(api_key="your-key") as client:
Expand All @@ -277,23 +277,15 @@ async with ScrapeBadger(api_key="your-key") as client:
print(f"{p['title']} — {p['price']['extracted']} from {p['source']} "
f"({p['rating']}★, {p['reviews']})")

# Step 2: per-product merchant URL enrichment (billed per call)
# Google has removed direct merchant links from organic Shopping HTML.
# The click endpoint uses an "I'm Feeling Lucky" redirect (scoped to
# the card's source merchant via the site: operator) to materialize
# the real product page URL. Mirrors
# immersive product link pattern.
# Step 2: full product detail with merchant offers. Pass the tile's
# gpcid plus the query that surfaced it.
first = products["results"][0]
enriched = await client.google.shopping.click(
title=first["title"],
source=first["source"], # scope: "site:walmart.com"
product_id=first["product_id"],
detail = await client.google.products.detail(
first["gpcid"], q="laptop", include_offers=True
)
print("Merchant URL:", enriched["merchant_url"])
# https://www.walmart.com/ip/Lenovo-IdeaPad-5-16IRU9-...

# Get detailed product information + seller list
detail = await client.google.shopping.product(first["product_id"])
# Multi-seller prices by the tile's catalog_id.
offers = await client.google.shopping.offers(catalog_id=first["catalog_id"], gl="us")

# Multi-seller prices by barcode (GTIN-8/UPC-A/EAN-13/GTIN-14).
# Resolves the barcode to a product, then returns its Shopping offers.
Expand Down Expand Up @@ -421,7 +413,7 @@ look-alikes and lists the `variants` it searched.
| `client.google.hotels` | Hotels: search, details |
| `client.google.trends` | Trends: interest, regions, related, trending |
| `client.google.jobs` | Job listings search |
| `client.google.shopping` | Shopping: search, product, click enrichment |
| `client.google.shopping` | Shopping: search, seller offers |
| `client.google.patents` | Patents: search, detail |
| `client.google.scholar` | Academic paper search |
| `client.google.autocomplete` | Search suggestion lookup |
Expand Down Expand Up @@ -456,9 +448,7 @@ look-alikes and lists the `variants` it searched.
| `trends` | `trending(*, geo)` | Real-time trending |
| `jobs` | `search(q, *, location, gl, job_type, date_posted)` | Job listings |
| `shopping` | `search(q, *, gl, min_price, max_price, sort_by)` | Product search |
| `shopping` | `product(product_id, *, gl)` | Product detail + sellers |
| `shopping` | `click(title, *, source, q, product_id, gl, hl)` | Merchant URL enrichment |
| `shopping` | `offers(barcode, *, gl, hl)` | Multi-seller prices by barcode |
| `shopping` | `offers(barcode, *, gl, hl, catalog_id)` | Multi-seller prices by barcode or catalog id |
| `patents` | `search(q, *, page, num, sort, inventor, assignee)` | Patent search |
| `patents` | `detail(patent_id)` | Patent document |
| `scholar` | `search(q, *, hl, as_ylo, as_yhi, as_sdt, page, num)` | Academic papers |
Expand Down Expand Up @@ -486,7 +476,6 @@ All methods are async and return `dict[str, Any]` responses matching the documen
| `ads/advertisers`, `ads/advertiser`, `ads/creative` | **15** |
| `ads/search` | **25** |
| `ads/advertisers` with `fuzzy=true` (billed as 3 lookups) | **45** |
| `shopping/product`, `shopping/product/click` | **1** |
| `resolve` (`/v1/google/resolve`) | **0** |
| Failed requests | **0** |

Expand All @@ -501,14 +490,6 @@ Google deployed **SearchGuard** in January 2025 — a JavaScript challenge that
3. Subsequent requests reuse the warm cookies for speed
4. On 429 or CAPTCHA, the cached residential proxy session is invalidated to rotate the exit IP (up to 3 rotations per request)

## Shopping Click Enrichment — Why It Exists

Google has removed direct merchant URLs from organic Shopping HTML — clicking a product card in the real Shopping UI opens a JavaScript modal that only fetches merchant info when you click "Visit site". Capturing that flow in a single synchronous scrape is impractical (~60-90s for 50 products).

Instead, the `shopping/product/click` endpoint exposes per-product merchant URL resolution as an **on-demand call** using Google's "I'm Feeling Lucky" redirect (`btnI=1`), scoped to the card's `source` merchant via a `site:` operator. You only pay for enrichment when you actually need the link — per-call credit cost is configured per-endpoint by admins (query `/public/pricing` for the live rate).

Known source → domain mappings include: Walmart, Best Buy, Amazon, Target, eBay, Newegg, Costco, Home Depot, Lowe's, Staples, Office Depot, Micro Center, Adorama, B&H Photo-Video-Pro Audio, HP, Dell, Lenovo, Apple, Razer, Asus, Acer, HyperX, MSI, Samsung. When the source is not in the map, the endpoint falls back to a bare-title query.

See the [full API documentation](https://docs.scrapebadger.com) for complete details on every endpoint, including Pydantic response schemas and all parameters.

---
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.86.0"
version = "0.87.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 @@ -1357,7 +1357,7 @@ async def main():
ZestimateHistoryPoint as ZillowZestimateHistoryPoint,
)

__version__ = "0.86.0"
__version__ = "0.87.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 @@ -59,7 +59,7 @@
_CONCURRENCY_ERRORS = frozenset({"concurrency_limit_exceeded", "trial_concurrency"})

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


Expand Down
7 changes: 3 additions & 4 deletions src/scrapebadger/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,10 @@ def google(self) -> GoogleClient:
# Maps search
places = await client.google.maps.search("coffee shops sf")

# Shopping search + merchant URL enrichment
# Shopping search + product detail with merchant offers
products = await client.google.shopping.search("laptop")
enrich = await client.google.shopping.click(
title=products["results"][0]["title"],
source=products["results"][0]["source"],
detail = await client.google.products.detail(
products["results"][0]["gpcid"], q="laptop", include_offers=True
)
```
"""
Expand Down
10 changes: 4 additions & 6 deletions src/scrapebadger/google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Google Hotels (search, details)
- Google Trends (interest, regions, related, trending, topic autocomplete)
- Google Jobs
- Google Shopping (search, product details, per-product merchant URL enrichment)
- Google Shopping (search, seller offers by barcode or catalog id)
- Google Patents (search, details)
- Google Scholar (search, profiles, author, author citation, cite formats)
- Google Autocomplete
Expand Down Expand Up @@ -36,14 +36,12 @@
# Maps search
places = await client.google.maps.search("pizza in New York")

# Shopping search + per-product click enrichment
# Shopping search + product detail with merchant offers
products = await client.google.shopping.search("laptop")
first = products["results"][0]
enrich = await client.google.shopping.click(
title=first["title"],
source=first["source"],
detail = await client.google.products.detail(
first["gpcid"], q="laptop", include_offers=True
)
print("Merchant URL:", enrich["merchant_url"])

# Flights
flights = await client.google.flights.search(
Expand Down
4 changes: 2 additions & 2 deletions src/scrapebadger/google/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GoogleClient:
hotels: Google Hotels (search, details).
trends: Google Trends (interest, regions, related, trending, autocomplete).
jobs: Google Jobs.
shopping: Google Shopping (search, product details, click enrichment).
shopping: Google Shopping (search, seller offers by barcode or catalog id).
patents: Google Patents (search, details).
scholar: Google Scholar (search, profiles, author, author citation, cite).
autocomplete: Google Autocomplete.
Expand Down Expand Up @@ -148,7 +148,7 @@ def jobs(self) -> JobsClient:

@property
def shopping(self) -> ShoppingClient:
"""Google Shopping — product search, details, per-product click enrichment."""
"""Google Shopping — product search and seller offers by barcode or catalog id."""
if self._shopping is None:
self._shopping = ShoppingClient(self._client)
return self._shopping
Expand Down
63 changes: 5 additions & 58 deletions src/scrapebadger/google/shopping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Google Shopping client (search and product detail)."""
"""Google Shopping client (search and seller offers)."""

from __future__ import annotations

Expand Down Expand Up @@ -71,9 +71,10 @@ async def search(

Returns:
Response with ``results`` (title, price.value + extracted_price,
source, rating, reviews, thumbnail, product_id, click_link,
delivery, on_sale/old_price/tag), ``filters``, ``ads``,
``pagination``.
source, rating, reviews, thumbnail, product_id, gpcid,
catalog_id, link, product_link,
scrapebadger_product_detail_link, delivery,
on_sale/old_price/tag), ``filters``, ``ads``, ``pagination``.
"""
params: dict[str, Any] = {
"q": q,
Expand Down Expand Up @@ -103,30 +104,6 @@ async def search(
params["shoprs"] = shoprs
return await self._client.get("/v1/google/shopping/search", params=params)

async def product(
self,
product_id: str,
*,
gl: str = "us",
hl: str = "en",
domain: str = "google.com",
) -> dict[str, Any]:
"""Fetch the Google Shopping product detail page.

Args:
product_id: Google Shopping product ID (from search results).
gl: Country code.
hl: Language code.
domain: Google domain.
"""
params: dict[str, Any] = {
"product_id": product_id,
"gl": gl,
"hl": hl,
"domain": domain,
}
return await self._client.get("/v1/google/shopping/product", params=params)

async def offers(
self,
barcode: str | None = None,
Expand Down Expand Up @@ -167,33 +144,3 @@ async def offers(
if gl is not None:
params["gl"] = gl
return await self._client.get("/v1/google/shopping/offers", params=params)

async def click(
self,
*,
title: str,
source: str,
q: str,
product_id: str | None = None,
) -> dict[str, Any]:
"""Resolve the direct merchant URL for a Shopping product tile.

Uses Google's "I'm Feeling Lucky" redirect (``btnI=1``) scoped to
the card's ``source`` merchant via the ``site:`` operator — so you
get the actual merchant product page URL without going through
Google's tracking redirect.

Args:
title: Product title from the original search result.
source: Merchant source name from the search result.
q: Original search query (helps Google disambiguate).
product_id: Optional product ID for correlation in the response.
"""
params: dict[str, Any] = {
"title": title,
"source": source,
"q": q,
}
if product_id is not None:
params["product_id"] = product_id
return await self._client.get("/v1/google/shopping/product/click", params=params)
26 changes: 4 additions & 22 deletions tests/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,6 @@ async def test_search(self, google: GoogleClient, mock_base_client: MagicMock) -
assert kwargs["params"]["min_price"] == 500
assert kwargs["params"]["sort_by"] == "price_low"

@pytest.mark.asyncio
async def test_product(self, google: GoogleClient, mock_base_client: MagicMock) -> None:
await google.shopping.product("abc123")
args, kwargs = mock_base_client.get.call_args
assert args[0] == "/v1/google/shopping/product"
assert kwargs["params"]["product_id"] == "abc123"

@pytest.mark.asyncio
async def test_offers(self, google: GoogleClient, mock_base_client: MagicMock) -> None:
await google.shopping.offers("0190198001751", gl="us")
Expand Down Expand Up @@ -657,21 +650,10 @@ async def test_offers_default_no_gl(
_, kwargs = mock_base_client.get.call_args
assert "gl" not in kwargs["params"]

@pytest.mark.asyncio
async def test_click(self, google: GoogleClient, mock_base_client: MagicMock) -> None:
await google.shopping.click(
title='Razer Blade 14"',
source="Razer.com",
q="gaming laptop",
product_id="pid123",
)
args, kwargs = mock_base_client.get.call_args
assert args[0] == "/v1/google/shopping/product/click"
params = kwargs["params"]
assert params["title"] == 'Razer Blade 14"'
assert params["source"] == "Razer.com"
assert params["q"] == "gaming laptop"
assert params["product_id"] == "pid123"
def test_retired_methods_are_gone(self, google: GoogleClient) -> None:
# /v1/google/shopping/product and /product/click were retired (404).
assert not hasattr(google.shopping, "product")
assert not hasattr(google.shopping, "click")


class TestPatentsClient:
Expand Down
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