scrapebadger 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
  var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
10
10
 
11
11
  // src/internal/version.ts
12
- var SDK_VERSION = "0.74.0";
12
+ var SDK_VERSION = "0.76.0";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -366,6 +366,9 @@ var BaseClient = class _BaseClient {
366
366
  async handleResponse(response) {
367
367
  let data;
368
368
  const contentType = response.headers.get("content-type");
369
+ if (response.ok && contentType?.includes("text/html")) {
370
+ return await response.text();
371
+ }
369
372
  if (contentType?.includes("application/json")) {
370
373
  data = await response.json();
371
374
  } else {
@@ -3536,73 +3539,17 @@ var SearchClient2 = class {
3536
3539
  constructor(client) {
3537
3540
  this.client = client;
3538
3541
  }
3539
- /**
3540
- * Search Google and get a structured SERP response with organic results,
3541
- * knowledge graph, People Also Ask, related searches, AI overview, and
3542
- * pagination.
3543
- *
3544
- * The response (untyped, `Record<string, unknown>`) holds, when Google
3545
- * shows them:
3546
- * - `search_information`: total_results, time_taken, query_displayed,
3547
- * organic_results_state (`"no_results"` on an explicit Google
3548
- * no-results answer, `"Results for relaxed query"` when Google drops
3549
- * quotes).
3550
- * - `organic_results`: position, title, link, snippet, displayed_link,
3551
- * plus `date`, `sitelinks`, `rich_snippet` and `read_more_link`.
3552
- * - `related_questions`: question, rank, `type` (`"ai_overview"` or
3553
- * `null`), and `text_blocks` / `references` with
3554
- * `expand_related_questions`.
3555
- * - `ai_overview`: `text_blocks` (paragraph, heading and list blocks; list
3556
- * blocks carry `list_items`) with `reference_indexes` (0-based into
3557
- * `references`), and `references` (title, link, source, snippet, logo).
3558
- * - `shopping_results`: position, category, title, price, extracted_price,
3559
- * original_price, extracted_original_price, source, rating, reviews,
3560
- * delivery, extensions, thumbnail, product_id, catalog_id, product_link,
3561
- * scrapebadger_product_detail_link.
3562
- * - `perspectives`, `discussions_and_forums`, `short_videos`,
3563
- * `things_to_know`, `ads`, `knowledge_graph`, `people_also_search_for`,
3564
- * `related_searches`, `local_results`, `inline_videos`, `pagination`.
3565
- *
3566
- * A full-mode query with a `site:` operator is answered from Google's Web
3567
- * tab: organic results, related searches and pagination only, rich blocks
3568
- * empty (pass `ai_overview: true` for the full page).
3569
- *
3570
- * @example
3571
- * ```typescript
3572
- * // People Also Ask answers for the first two questions
3573
- * const serp = await client.google.search.search({
3574
- * q: "are noise cancelling headphones worth it",
3575
- * expand_related_questions: 2,
3576
- * });
3577
- * ```
3578
- */
3579
3542
  async search(params) {
3580
- return this.client.request("/v1/google/search", { params: { ...params } });
3543
+ return this.client.request("/v1/google/search", {
3544
+ params: { ...params }
3545
+ });
3581
3546
  }
3582
- /**
3583
- * Google Light Search — organic results + related searches only.
3584
- *
3585
- * Calls the dedicated `/v1/google/light/search` endpoint, billed at the
3586
- * Light rate (half of full {@link search}; query `/public/pricing` for the
3587
- * live rate). Skips ads, Knowledge Graph, AI Overview, People Also Ask,
3588
- * local pack, news, inline videos, and shopping blocks. Has a 12-second
3589
- * processing budget; past it the API returns `503` with
3590
- * `Retry-After: 60`. Light cannot be upgraded to full Search, so
3591
- * `ai_overview` is not sent; AI Overview and People Also Ask answers
3592
- * (`expand_related_questions`) need {@link search}.
3593
- *
3594
- * Returns `{ search_information, organic_results, related_searches,
3595
- * pagination }`.
3596
- *
3597
- * @example
3598
- * ```typescript
3599
- * const lite = await client.google.search.light({ q: "python 3.13" });
3600
- * ```
3601
- */
3602
3547
  async light(params) {
3603
3548
  const light = { ...params };
3604
3549
  for (const key of FULL_SEARCH_ONLY) delete light[key];
3605
- return this.client.request("/v1/google/light/search", { params: light });
3550
+ return this.client.request("/v1/google/light/search", {
3551
+ params: light
3552
+ });
3606
3553
  }
3607
3554
  };
3608
3555