scrapebadger 0.74.0 → 0.75.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.d.cts CHANGED
@@ -1180,17 +1180,59 @@ declare class VintedClient {
1180
1180
  */
1181
1181
  type GoogleResponse = Record<string, unknown>;
1182
1182
  interface GoogleSearchParams {
1183
+ /** Alias for domain; Google requests use google.com with country targeting. */
1184
+ google_domain?: string;
1185
+ /** Latitude; supply together with lon instead of location or uule. */
1186
+ lat?: number;
1187
+ /** Longitude; supply together with lat. */
1188
+ lon?: number;
1189
+ /** Location accuracy in meters; requires lat/lon or a named city with a known center. */
1190
+ radius?: number;
1191
+ /** Google color scheme. */
1192
+ color_scheme?: "light" | "dark";
1193
+ /** Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results. */
1194
+ tbm?: string;
1195
+ /** Google result filter: 14 web, 18 forums. Other verticals require output=html. */
1196
+ udm?: string;
1197
+ /** Bypass result caches and request a fresh Google fetch. */
1198
+ no_cache?: boolean;
1199
+ /** Site restriction mode: i includes, e excludes as_sitesearch. */
1200
+ as_dt?: string;
1201
+ /** Exact phrase. */
1202
+ as_epq?: string;
1203
+ /** Words to exclude. */
1204
+ as_eq?: string;
1205
+ /** Find pages linking to this URL; availability depends on Google. */
1206
+ as_lq?: string;
1207
+ /** Numeric range minimum. */
1208
+ as_nlo?: string;
1209
+ /** Numeric range maximum. */
1210
+ as_nhi?: string;
1211
+ /** Match any of these words. */
1212
+ as_oq?: string;
1213
+ /** Additional query words. */
1214
+ as_q?: string;
1215
+ /** Time range, such as d, w, m or y1. */
1216
+ as_qdr?: string;
1217
+ /** Related URL; availability depends on Google. */
1218
+ as_rq?: string;
1219
+ /** Restrict results to a site. */
1220
+ as_sitesearch?: string;
1221
+ /** Custom User-Agent override. */
1222
+ user_agent?: string;
1223
+ /** json returns structured results; html returns the raw page. */
1224
+ output?: "json" | "html";
1183
1225
  q: string;
1184
1226
  gl?: string;
1185
1227
  hl?: string;
1186
1228
  num?: number;
1187
1229
  start?: number;
1188
1230
  domain?: string;
1189
- device?: "desktop" | "mobile";
1231
+ device?: "desktop" | "mobile" | "iphone" | "android" | "tablet";
1190
1232
  location?: string;
1191
1233
  lr?: string;
1192
1234
  tbs?: string;
1193
- safe?: "off" | "medium" | "high";
1235
+ safe?: "off" | "active" | "medium" | "high";
1194
1236
  uule?: string;
1195
1237
  filter?: number;
1196
1238
  nfpr?: number;
@@ -2528,7 +2570,13 @@ declare class SearchClient$h {
2528
2570
  * });
2529
2571
  * ```
2530
2572
  */
2531
- search(params: GoogleSearchParams): Promise<GoogleResponse>;
2573
+ search(params: GoogleSearchParams & {
2574
+ output: "html";
2575
+ }): Promise<string>;
2576
+ search(params: GoogleSearchParams & {
2577
+ output?: "json";
2578
+ }): Promise<GoogleResponse>;
2579
+ search(params: GoogleSearchParams): Promise<GoogleResponse | string>;
2532
2580
  /**
2533
2581
  * Google Light Search — organic results + related searches only.
2534
2582
  *
@@ -2549,7 +2597,13 @@ declare class SearchClient$h {
2549
2597
  * const lite = await client.google.search.light({ q: "python 3.13" });
2550
2598
  * ```
2551
2599
  */
2552
- light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse>;
2600
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
2601
+ output: "html";
2602
+ }): Promise<string>;
2603
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
2604
+ output?: "json";
2605
+ }): Promise<GoogleResponse>;
2606
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse | string>;
2553
2607
  }
2554
2608
 
2555
2609
  /**
package/dist/index.d.ts CHANGED
@@ -1180,17 +1180,59 @@ declare class VintedClient {
1180
1180
  */
1181
1181
  type GoogleResponse = Record<string, unknown>;
1182
1182
  interface GoogleSearchParams {
1183
+ /** Alias for domain; Google requests use google.com with country targeting. */
1184
+ google_domain?: string;
1185
+ /** Latitude; supply together with lon instead of location or uule. */
1186
+ lat?: number;
1187
+ /** Longitude; supply together with lat. */
1188
+ lon?: number;
1189
+ /** Location accuracy in meters; requires lat/lon or a named city with a known center. */
1190
+ radius?: number;
1191
+ /** Google color scheme. */
1192
+ color_scheme?: "light" | "dark";
1193
+ /** Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results. */
1194
+ tbm?: string;
1195
+ /** Google result filter: 14 web, 18 forums. Other verticals require output=html. */
1196
+ udm?: string;
1197
+ /** Bypass result caches and request a fresh Google fetch. */
1198
+ no_cache?: boolean;
1199
+ /** Site restriction mode: i includes, e excludes as_sitesearch. */
1200
+ as_dt?: string;
1201
+ /** Exact phrase. */
1202
+ as_epq?: string;
1203
+ /** Words to exclude. */
1204
+ as_eq?: string;
1205
+ /** Find pages linking to this URL; availability depends on Google. */
1206
+ as_lq?: string;
1207
+ /** Numeric range minimum. */
1208
+ as_nlo?: string;
1209
+ /** Numeric range maximum. */
1210
+ as_nhi?: string;
1211
+ /** Match any of these words. */
1212
+ as_oq?: string;
1213
+ /** Additional query words. */
1214
+ as_q?: string;
1215
+ /** Time range, such as d, w, m or y1. */
1216
+ as_qdr?: string;
1217
+ /** Related URL; availability depends on Google. */
1218
+ as_rq?: string;
1219
+ /** Restrict results to a site. */
1220
+ as_sitesearch?: string;
1221
+ /** Custom User-Agent override. */
1222
+ user_agent?: string;
1223
+ /** json returns structured results; html returns the raw page. */
1224
+ output?: "json" | "html";
1183
1225
  q: string;
1184
1226
  gl?: string;
1185
1227
  hl?: string;
1186
1228
  num?: number;
1187
1229
  start?: number;
1188
1230
  domain?: string;
1189
- device?: "desktop" | "mobile";
1231
+ device?: "desktop" | "mobile" | "iphone" | "android" | "tablet";
1190
1232
  location?: string;
1191
1233
  lr?: string;
1192
1234
  tbs?: string;
1193
- safe?: "off" | "medium" | "high";
1235
+ safe?: "off" | "active" | "medium" | "high";
1194
1236
  uule?: string;
1195
1237
  filter?: number;
1196
1238
  nfpr?: number;
@@ -2528,7 +2570,13 @@ declare class SearchClient$h {
2528
2570
  * });
2529
2571
  * ```
2530
2572
  */
2531
- search(params: GoogleSearchParams): Promise<GoogleResponse>;
2573
+ search(params: GoogleSearchParams & {
2574
+ output: "html";
2575
+ }): Promise<string>;
2576
+ search(params: GoogleSearchParams & {
2577
+ output?: "json";
2578
+ }): Promise<GoogleResponse>;
2579
+ search(params: GoogleSearchParams): Promise<GoogleResponse | string>;
2532
2580
  /**
2533
2581
  * Google Light Search — organic results + related searches only.
2534
2582
  *
@@ -2549,7 +2597,13 @@ declare class SearchClient$h {
2549
2597
  * const lite = await client.google.search.light({ q: "python 3.13" });
2550
2598
  * ```
2551
2599
  */
2552
- light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse>;
2600
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
2601
+ output: "html";
2602
+ }): Promise<string>;
2603
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
2604
+ output?: "json";
2605
+ }): Promise<GoogleResponse>;
2606
+ light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse | string>;
2553
2607
  }
2554
2608
 
2555
2609
  /**
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import WebSocket from 'ws';
4
4
 
5
5
  // src/internal/version.ts
6
- var SDK_VERSION = "0.74.0";
6
+ var SDK_VERSION = "0.75.0";
7
7
 
8
8
  // src/internal/exceptions.ts
9
9
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -360,6 +360,9 @@ var BaseClient = class _BaseClient {
360
360
  async handleResponse(response) {
361
361
  let data;
362
362
  const contentType = response.headers.get("content-type");
363
+ if (response.ok && contentType?.includes("text/html")) {
364
+ return await response.text();
365
+ }
363
366
  if (contentType?.includes("application/json")) {
364
367
  data = await response.json();
365
368
  } else {
@@ -3530,73 +3533,17 @@ var SearchClient2 = class {
3530
3533
  constructor(client) {
3531
3534
  this.client = client;
3532
3535
  }
3533
- /**
3534
- * Search Google and get a structured SERP response with organic results,
3535
- * knowledge graph, People Also Ask, related searches, AI overview, and
3536
- * pagination.
3537
- *
3538
- * The response (untyped, `Record<string, unknown>`) holds, when Google
3539
- * shows them:
3540
- * - `search_information`: total_results, time_taken, query_displayed,
3541
- * organic_results_state (`"no_results"` on an explicit Google
3542
- * no-results answer, `"Results for relaxed query"` when Google drops
3543
- * quotes).
3544
- * - `organic_results`: position, title, link, snippet, displayed_link,
3545
- * plus `date`, `sitelinks`, `rich_snippet` and `read_more_link`.
3546
- * - `related_questions`: question, rank, `type` (`"ai_overview"` or
3547
- * `null`), and `text_blocks` / `references` with
3548
- * `expand_related_questions`.
3549
- * - `ai_overview`: `text_blocks` (paragraph, heading and list blocks; list
3550
- * blocks carry `list_items`) with `reference_indexes` (0-based into
3551
- * `references`), and `references` (title, link, source, snippet, logo).
3552
- * - `shopping_results`: position, category, title, price, extracted_price,
3553
- * original_price, extracted_original_price, source, rating, reviews,
3554
- * delivery, extensions, thumbnail, product_id, catalog_id, product_link,
3555
- * scrapebadger_product_detail_link.
3556
- * - `perspectives`, `discussions_and_forums`, `short_videos`,
3557
- * `things_to_know`, `ads`, `knowledge_graph`, `people_also_search_for`,
3558
- * `related_searches`, `local_results`, `inline_videos`, `pagination`.
3559
- *
3560
- * A full-mode query with a `site:` operator is answered from Google's Web
3561
- * tab: organic results, related searches and pagination only, rich blocks
3562
- * empty (pass `ai_overview: true` for the full page).
3563
- *
3564
- * @example
3565
- * ```typescript
3566
- * // People Also Ask answers for the first two questions
3567
- * const serp = await client.google.search.search({
3568
- * q: "are noise cancelling headphones worth it",
3569
- * expand_related_questions: 2,
3570
- * });
3571
- * ```
3572
- */
3573
3536
  async search(params) {
3574
- return this.client.request("/v1/google/search", { params: { ...params } });
3537
+ return this.client.request("/v1/google/search", {
3538
+ params: { ...params }
3539
+ });
3575
3540
  }
3576
- /**
3577
- * Google Light Search — organic results + related searches only.
3578
- *
3579
- * Calls the dedicated `/v1/google/light/search` endpoint, billed at the
3580
- * Light rate (half of full {@link search}; query `/public/pricing` for the
3581
- * live rate). Skips ads, Knowledge Graph, AI Overview, People Also Ask,
3582
- * local pack, news, inline videos, and shopping blocks. Has a 12-second
3583
- * processing budget; past it the API returns `503` with
3584
- * `Retry-After: 60`. Light cannot be upgraded to full Search, so
3585
- * `ai_overview` is not sent; AI Overview and People Also Ask answers
3586
- * (`expand_related_questions`) need {@link search}.
3587
- *
3588
- * Returns `{ search_information, organic_results, related_searches,
3589
- * pagination }`.
3590
- *
3591
- * @example
3592
- * ```typescript
3593
- * const lite = await client.google.search.light({ q: "python 3.13" });
3594
- * ```
3595
- */
3596
3541
  async light(params) {
3597
3542
  const light = { ...params };
3598
3543
  for (const key of FULL_SEARCH_ONLY) delete light[key];
3599
- return this.client.request("/v1/google/light/search", { params: light });
3544
+ return this.client.request("/v1/google/light/search", {
3545
+ params: light
3546
+ });
3600
3547
  }
3601
3548
  };
3602
3549