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 +10 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -4
- package/dist/index.d.ts +64 -4
- package/dist/index.mjs +10 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1180,17 +1180,65 @@ declare class VintedClient {
|
|
|
1180
1180
|
*/
|
|
1181
1181
|
type GoogleResponse = Record<string, unknown>;
|
|
1182
1182
|
interface GoogleSearchParams {
|
|
1183
|
+
/** Original query sent to Google. Defaults to q; an empty string omits it. */
|
|
1184
|
+
oq?: string;
|
|
1185
|
+
/** Google source identifier. Defaults to chrome; an empty string omits it. */
|
|
1186
|
+
sourceid?: string;
|
|
1187
|
+
/** Google input encoding hint. Defaults to UTF-8; an empty string omits it. */
|
|
1188
|
+
ie?: string;
|
|
1189
|
+
/** Alias for domain; Google requests use google.com with country targeting. */
|
|
1190
|
+
google_domain?: string;
|
|
1191
|
+
/** Latitude; supply together with lon instead of location or uule. */
|
|
1192
|
+
lat?: number;
|
|
1193
|
+
/** Longitude; supply together with lat. */
|
|
1194
|
+
lon?: number;
|
|
1195
|
+
/** Location accuracy in meters; requires lat/lon or a named city with a known center. */
|
|
1196
|
+
radius?: number;
|
|
1197
|
+
/** Google color scheme. */
|
|
1198
|
+
color_scheme?: "light" | "dark";
|
|
1199
|
+
/** Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results. */
|
|
1200
|
+
tbm?: string;
|
|
1201
|
+
/** Google result filter: 14 web, 18 forums. Other verticals require output=html. */
|
|
1202
|
+
udm?: string;
|
|
1203
|
+
/** Bypass result caches and request a fresh Google fetch. */
|
|
1204
|
+
no_cache?: boolean;
|
|
1205
|
+
/** Site restriction mode: i includes, e excludes as_sitesearch. */
|
|
1206
|
+
as_dt?: string;
|
|
1207
|
+
/** Exact phrase. */
|
|
1208
|
+
as_epq?: string;
|
|
1209
|
+
/** Words to exclude. */
|
|
1210
|
+
as_eq?: string;
|
|
1211
|
+
/** Find pages linking to this URL; availability depends on Google. */
|
|
1212
|
+
as_lq?: string;
|
|
1213
|
+
/** Numeric range minimum. */
|
|
1214
|
+
as_nlo?: string;
|
|
1215
|
+
/** Numeric range maximum. */
|
|
1216
|
+
as_nhi?: string;
|
|
1217
|
+
/** Match any of these words. */
|
|
1218
|
+
as_oq?: string;
|
|
1219
|
+
/** Additional query words. */
|
|
1220
|
+
as_q?: string;
|
|
1221
|
+
/** Time range, such as d, w, m or y1. */
|
|
1222
|
+
as_qdr?: string;
|
|
1223
|
+
/** Related URL; availability depends on Google. */
|
|
1224
|
+
as_rq?: string;
|
|
1225
|
+
/** Restrict results to a site. */
|
|
1226
|
+
as_sitesearch?: string;
|
|
1227
|
+
/** Custom User-Agent override. */
|
|
1228
|
+
user_agent?: string;
|
|
1229
|
+
/** json returns structured results; html returns the raw page. */
|
|
1230
|
+
output?: "json" | "html";
|
|
1183
1231
|
q: string;
|
|
1184
1232
|
gl?: string;
|
|
1185
1233
|
hl?: string;
|
|
1186
1234
|
num?: number;
|
|
1187
1235
|
start?: number;
|
|
1188
1236
|
domain?: string;
|
|
1189
|
-
device?: "desktop" | "mobile";
|
|
1237
|
+
device?: "desktop" | "mobile" | "iphone" | "android" | "tablet";
|
|
1190
1238
|
location?: string;
|
|
1191
1239
|
lr?: string;
|
|
1192
1240
|
tbs?: string;
|
|
1193
|
-
safe?: "off" | "medium" | "high";
|
|
1241
|
+
safe?: "off" | "active" | "medium" | "high";
|
|
1194
1242
|
uule?: string;
|
|
1195
1243
|
filter?: number;
|
|
1196
1244
|
nfpr?: number;
|
|
@@ -2528,7 +2576,13 @@ declare class SearchClient$h {
|
|
|
2528
2576
|
* });
|
|
2529
2577
|
* ```
|
|
2530
2578
|
*/
|
|
2531
|
-
search(params: GoogleSearchParams
|
|
2579
|
+
search(params: GoogleSearchParams & {
|
|
2580
|
+
output: "html";
|
|
2581
|
+
}): Promise<string>;
|
|
2582
|
+
search(params: GoogleSearchParams & {
|
|
2583
|
+
output?: "json";
|
|
2584
|
+
}): Promise<GoogleResponse>;
|
|
2585
|
+
search(params: GoogleSearchParams): Promise<GoogleResponse | string>;
|
|
2532
2586
|
/**
|
|
2533
2587
|
* Google Light Search — organic results + related searches only.
|
|
2534
2588
|
*
|
|
@@ -2549,7 +2603,13 @@ declare class SearchClient$h {
|
|
|
2549
2603
|
* const lite = await client.google.search.light({ q: "python 3.13" });
|
|
2550
2604
|
* ```
|
|
2551
2605
|
*/
|
|
2552
|
-
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">
|
|
2606
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
|
|
2607
|
+
output: "html";
|
|
2608
|
+
}): Promise<string>;
|
|
2609
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
|
|
2610
|
+
output?: "json";
|
|
2611
|
+
}): Promise<GoogleResponse>;
|
|
2612
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse | string>;
|
|
2553
2613
|
}
|
|
2554
2614
|
|
|
2555
2615
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1180,17 +1180,65 @@ declare class VintedClient {
|
|
|
1180
1180
|
*/
|
|
1181
1181
|
type GoogleResponse = Record<string, unknown>;
|
|
1182
1182
|
interface GoogleSearchParams {
|
|
1183
|
+
/** Original query sent to Google. Defaults to q; an empty string omits it. */
|
|
1184
|
+
oq?: string;
|
|
1185
|
+
/** Google source identifier. Defaults to chrome; an empty string omits it. */
|
|
1186
|
+
sourceid?: string;
|
|
1187
|
+
/** Google input encoding hint. Defaults to UTF-8; an empty string omits it. */
|
|
1188
|
+
ie?: string;
|
|
1189
|
+
/** Alias for domain; Google requests use google.com with country targeting. */
|
|
1190
|
+
google_domain?: string;
|
|
1191
|
+
/** Latitude; supply together with lon instead of location or uule. */
|
|
1192
|
+
lat?: number;
|
|
1193
|
+
/** Longitude; supply together with lat. */
|
|
1194
|
+
lon?: number;
|
|
1195
|
+
/** Location accuracy in meters; requires lat/lon or a named city with a known center. */
|
|
1196
|
+
radius?: number;
|
|
1197
|
+
/** Google color scheme. */
|
|
1198
|
+
color_scheme?: "light" | "dark";
|
|
1199
|
+
/** Google search type. Use output=html for verticals; dedicated APIs provide parsed vertical results. */
|
|
1200
|
+
tbm?: string;
|
|
1201
|
+
/** Google result filter: 14 web, 18 forums. Other verticals require output=html. */
|
|
1202
|
+
udm?: string;
|
|
1203
|
+
/** Bypass result caches and request a fresh Google fetch. */
|
|
1204
|
+
no_cache?: boolean;
|
|
1205
|
+
/** Site restriction mode: i includes, e excludes as_sitesearch. */
|
|
1206
|
+
as_dt?: string;
|
|
1207
|
+
/** Exact phrase. */
|
|
1208
|
+
as_epq?: string;
|
|
1209
|
+
/** Words to exclude. */
|
|
1210
|
+
as_eq?: string;
|
|
1211
|
+
/** Find pages linking to this URL; availability depends on Google. */
|
|
1212
|
+
as_lq?: string;
|
|
1213
|
+
/** Numeric range minimum. */
|
|
1214
|
+
as_nlo?: string;
|
|
1215
|
+
/** Numeric range maximum. */
|
|
1216
|
+
as_nhi?: string;
|
|
1217
|
+
/** Match any of these words. */
|
|
1218
|
+
as_oq?: string;
|
|
1219
|
+
/** Additional query words. */
|
|
1220
|
+
as_q?: string;
|
|
1221
|
+
/** Time range, such as d, w, m or y1. */
|
|
1222
|
+
as_qdr?: string;
|
|
1223
|
+
/** Related URL; availability depends on Google. */
|
|
1224
|
+
as_rq?: string;
|
|
1225
|
+
/** Restrict results to a site. */
|
|
1226
|
+
as_sitesearch?: string;
|
|
1227
|
+
/** Custom User-Agent override. */
|
|
1228
|
+
user_agent?: string;
|
|
1229
|
+
/** json returns structured results; html returns the raw page. */
|
|
1230
|
+
output?: "json" | "html";
|
|
1183
1231
|
q: string;
|
|
1184
1232
|
gl?: string;
|
|
1185
1233
|
hl?: string;
|
|
1186
1234
|
num?: number;
|
|
1187
1235
|
start?: number;
|
|
1188
1236
|
domain?: string;
|
|
1189
|
-
device?: "desktop" | "mobile";
|
|
1237
|
+
device?: "desktop" | "mobile" | "iphone" | "android" | "tablet";
|
|
1190
1238
|
location?: string;
|
|
1191
1239
|
lr?: string;
|
|
1192
1240
|
tbs?: string;
|
|
1193
|
-
safe?: "off" | "medium" | "high";
|
|
1241
|
+
safe?: "off" | "active" | "medium" | "high";
|
|
1194
1242
|
uule?: string;
|
|
1195
1243
|
filter?: number;
|
|
1196
1244
|
nfpr?: number;
|
|
@@ -2528,7 +2576,13 @@ declare class SearchClient$h {
|
|
|
2528
2576
|
* });
|
|
2529
2577
|
* ```
|
|
2530
2578
|
*/
|
|
2531
|
-
search(params: GoogleSearchParams
|
|
2579
|
+
search(params: GoogleSearchParams & {
|
|
2580
|
+
output: "html";
|
|
2581
|
+
}): Promise<string>;
|
|
2582
|
+
search(params: GoogleSearchParams & {
|
|
2583
|
+
output?: "json";
|
|
2584
|
+
}): Promise<GoogleResponse>;
|
|
2585
|
+
search(params: GoogleSearchParams): Promise<GoogleResponse | string>;
|
|
2532
2586
|
/**
|
|
2533
2587
|
* Google Light Search — organic results + related searches only.
|
|
2534
2588
|
*
|
|
@@ -2549,7 +2603,13 @@ declare class SearchClient$h {
|
|
|
2549
2603
|
* const lite = await client.google.search.light({ q: "python 3.13" });
|
|
2550
2604
|
* ```
|
|
2551
2605
|
*/
|
|
2552
|
-
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">
|
|
2606
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
|
|
2607
|
+
output: "html";
|
|
2608
|
+
}): Promise<string>;
|
|
2609
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions"> & {
|
|
2610
|
+
output?: "json";
|
|
2611
|
+
}): Promise<GoogleResponse>;
|
|
2612
|
+
light(params: Omit<GoogleSearchParams, "mode" | "expand_related_questions">): Promise<GoogleResponse | string>;
|
|
2553
2613
|
}
|
|
2554
2614
|
|
|
2555
2615
|
/**
|
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.
|
|
6
|
+
var SDK_VERSION = "0.76.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", {
|
|
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", {
|
|
3544
|
+
return this.client.request("/v1/google/light/search", {
|
|
3545
|
+
params: light
|
|
3546
|
+
});
|
|
3600
3547
|
}
|
|
3601
3548
|
};
|
|
3602
3549
|
|