From 0c010dd393964b14131d49df0a695c3031c64ffe Mon Sep 17 00:00:00 2001 From: kasparasizi1 <132673909+kasparasizi1@users.noreply.github.com> Date: Tue, 1 Dec 2026 03:17:21 +0200 Subject: [PATCH] feat(google)!: remove shopping.product() and shopping.click() (0.87.0, SCR-764) GET /v1/google/shopping/product and GET /v1/google/shopping/product/click were retired (monorepo migrations 059/060) and answer 404, so both methods could only fail. A customer called them from our examples (SB-001278). - ShoppingClient loses product() and click(); offers() and search() stay. - Docstring examples in client.py and google/__init__.py now chain shopping.search() into products.detail(gpcid, q=..., include_offers=True). - search() docstring lists the tile fields Google returns today (gpcid, catalog_id, link, product_link, scrapebadger_product_detail_link); there is no click_link. - docs/google.md: shopping example, method tables, credit table and the "Shopping Click Enrichment" section updated or removed. - Version 0.87.0 and a CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 +++ README.md | 2 +- docs/google.md | 37 ++++------------ pyproject.toml | 2 +- src/scrapebadger/__init__.py | 2 +- src/scrapebadger/_internal/client.py | 2 +- src/scrapebadger/client.py | 7 ++-- src/scrapebadger/google/__init__.py | 10 ++--- src/scrapebadger/google/client.py | 4 +- src/scrapebadger/google/shopping.py | 63 +++------------------------- tests/test_google.py | 26 ++---------- uv.lock | 2 +- 12 files changed, 37 insertions(+), 125 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83ba50a..809e0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index a55e09b..15d3dc8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/google.md b/docs/google.md index 3be2f5e..a0cc1c7 100644 --- a/docs/google.md +++ b/docs/google.md @@ -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: @@ -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. @@ -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 | @@ -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 | @@ -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** | @@ -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. --- diff --git a/pyproject.toml b/pyproject.toml index f0f0e78..cb19245 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" } diff --git a/src/scrapebadger/__init__.py b/src/scrapebadger/__init__.py index f8c0021..8136b38 100644 --- a/src/scrapebadger/__init__.py +++ b/src/scrapebadger/__init__.py @@ -1357,7 +1357,7 @@ async def main(): ZestimateHistoryPoint as ZillowZestimateHistoryPoint, ) -__version__ = "0.86.0" +__version__ = "0.87.0" __all__ = [ # TikTok core models diff --git a/src/scrapebadger/_internal/client.py b/src/scrapebadger/_internal/client.py index 8f2b9ac..8198b46 100644 --- a/src/scrapebadger/_internal/client.py +++ b/src/scrapebadger/_internal/client.py @@ -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}" diff --git a/src/scrapebadger/client.py b/src/scrapebadger/client.py index e932fc4..bed9998 100644 --- a/src/scrapebadger/client.py +++ b/src/scrapebadger/client.py @@ -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 ) ``` """ diff --git a/src/scrapebadger/google/__init__.py b/src/scrapebadger/google/__init__.py index c46e1c1..7016e1e 100644 --- a/src/scrapebadger/google/__init__.py +++ b/src/scrapebadger/google/__init__.py @@ -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 @@ -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( diff --git a/src/scrapebadger/google/client.py b/src/scrapebadger/google/client.py index 1297c6a..bcf3f6a 100644 --- a/src/scrapebadger/google/client.py +++ b/src/scrapebadger/google/client.py @@ -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. @@ -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 diff --git a/src/scrapebadger/google/shopping.py b/src/scrapebadger/google/shopping.py index 4afaa1d..57c8428 100644 --- a/src/scrapebadger/google/shopping.py +++ b/src/scrapebadger/google/shopping.py @@ -1,4 +1,4 @@ -"""Google Shopping client (search and product detail).""" +"""Google Shopping client (search and seller offers).""" from __future__ import annotations @@ -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, @@ -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, @@ -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) diff --git a/tests/test_google.py b/tests/test_google.py index 26cadb6..f808cd3 100644 --- a/tests/test_google.py +++ b/tests/test_google.py @@ -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") @@ -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: diff --git a/uv.lock b/uv.lock index b6dc92c..bf40110 100644 --- a/uv.lock +++ b/uv.lock @@ -930,7 +930,7 @@ wheels = [ [[package]] name = "scrapebadger" -version = "0.86.0" +version = "0.87.0" source = { editable = "." } dependencies = [ { name = "httpx" },