scrapebadger 0.60.1 → 0.61.1

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.js 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.60.1";
12
+ var SDK_VERSION = "0.61.1";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -88,6 +88,25 @@ var ValidationError = class _ValidationError extends ScrapeBadgerError {
88
88
  Object.setPrototypeOf(this, _ValidationError.prototype);
89
89
  }
90
90
  };
91
+ var BlockedError = class _BlockedError extends ValidationError {
92
+ /** The wall's class; undefined on older responses */
93
+ blockKind;
94
+ /** The protection vendor that served it, e.g. "cloudflare", "datadome", "aws_waf" */
95
+ vendor;
96
+ /** The CAPTCHA gating the page when blockKind is "captcha" */
97
+ captcha;
98
+ /** The scrape result the API returned with the block */
99
+ data;
100
+ constructor(message = "Blocking page detected.", details = {}) {
101
+ super(message);
102
+ this.name = "BlockedError";
103
+ this.blockKind = details.blockKind ?? void 0;
104
+ this.vendor = details.vendor ?? void 0;
105
+ this.captcha = details.captcha ?? void 0;
106
+ this.data = details.data ?? void 0;
107
+ Object.setPrototypeOf(this, _BlockedError.prototype);
108
+ }
109
+ };
91
110
  var ServerError = class _ServerError extends ScrapeBadgerError {
92
111
  /** HTTP status code */
93
112
  statusCode;
@@ -383,6 +402,14 @@ var BaseClient = class _BaseClient {
383
402
  case 409:
384
403
  throw new ConflictError(message);
385
404
  case 422:
405
+ if (errorData.error === "blocking_page_detected") {
406
+ throw new BlockedError(message, {
407
+ blockKind: errorData.block_kind,
408
+ vendor: errorData.vendor,
409
+ captcha: errorData.captcha,
410
+ data: errorData.data
411
+ });
412
+ }
386
413
  throw new ValidationError(message, errorData.errors);
387
414
  case 429:
388
415
  throw new RateLimitError(message, {
@@ -7005,8 +7032,6 @@ var BaiduClient = class {
7005
7032
  /**
7006
7033
  * Search baidu.com — the web SERP.
7007
7034
  *
7008
- * Costs 5 credits.
7009
- *
7010
7035
  * @param query - Search keywords, e.g. `"咖啡机"` or `"coffee machine"` (required).
7011
7036
  * @param options - Optional parameters (page, num, language, timeFrom, timeTo).
7012
7037
  * @returns Search response with organic results and Baidu's related searches.
@@ -7028,8 +7053,6 @@ var BaiduClient = class {
7028
7053
  /**
7029
7054
  * Search the Baidu news vertical.
7030
7055
  *
7031
- * Costs 5 credits.
7032
- *
7033
7056
  * @param query - Search keywords, e.g. `"人工智能"` (required).
7034
7057
  * @param options - Optional parameters (page, sort).
7035
7058
  * @returns News response with articles carrying publisher, date and real URLs.
@@ -7044,8 +7067,6 @@ var BaiduClient = class {
7044
7067
  /**
7045
7068
  * Search Baidu images.
7046
7069
  *
7047
- * Costs 5 credits.
7048
- *
7049
7070
  * @param query - Search keywords, e.g. `"猫"` (required).
7050
7071
  * @param options - Optional parameters (page). Baidu serves 30 images per page.
7051
7072
  * @returns Images response with full-size image URLs, Baidu-hosted thumbnail
@@ -7061,8 +7082,6 @@ var BaiduClient = class {
7061
7082
  /**
7062
7083
  * Baidu search-box suggestions — the cheapest call in this API.
7063
7084
  *
7064
- * Costs 1 credit.
7065
- *
7066
7085
  * @param query - Partial search term, e.g. `"咖啡"` or `"coff"` (required).
7067
7086
  * @returns Autocomplete response with Baidu's suggestions for the term.
7068
7087
  * @throws AuthenticationError - If the API key is invalid.
@@ -9238,8 +9257,6 @@ var SearchClient19 = class {
9238
9257
  /**
9239
9258
  * Search LoopNet for for-lease / for-sale / auction commercial listings.
9240
9259
  *
9241
- * Costs 10 credits.
9242
- *
9243
9260
  * @param params - Search parameters including location, filters, and pagination.
9244
9261
  * @returns Search results with listing cards and pagination metadata.
9245
9262
  * @throws AuthenticationError - If the API key is invalid.
@@ -9272,8 +9289,6 @@ var ListingsClient2 = class {
9272
9289
  /**
9273
9290
  * Get a single LoopNet listing's full detail by listing id.
9274
9291
  *
9275
- * Costs 12 credits.
9276
- *
9277
9292
  * @param listingId - The LoopNet listing id.
9278
9293
  * @param params - Optional market selector.
9279
9294
  * @returns Listing detail response.
@@ -9295,8 +9310,6 @@ var BrokersClient = class {
9295
9310
  /**
9296
9311
  * Get a LoopNet broker's profile and their active listings.
9297
9312
  *
9298
- * Costs 8 credits.
9299
- *
9300
9313
  * @param slug - The broker's profile URL slug.
9301
9314
  * @param brokerId - The LoopNet broker id.
9302
9315
  * @param params - Optional market selector.
@@ -9396,8 +9409,6 @@ var DepopClient = class {
9396
9409
  /**
9397
9410
  * Search Depop for products.
9398
9411
  *
9399
- * Costs 10 credits.
9400
- *
9401
9412
  * @param query - Search keywords (required).
9402
9413
  * @param options - Optional parameters (market, perPage, page, price/brand/
9403
9414
  * size/colour/condition/gender filters, sort).
@@ -9426,8 +9437,6 @@ var DepopClient = class {
9426
9437
  /**
9427
9438
  * Get a single Depop product's full detail by slug.
9428
9439
  *
9429
- * Costs 10 credits.
9430
- *
9431
9440
  * @param slug - The Depop product slug.
9432
9441
  * @param options - Optional parameters (market).
9433
9442
  * @returns Full product detail.
@@ -9441,8 +9450,6 @@ var DepopClient = class {
9441
9450
  /**
9442
9451
  * Get a Depop shop / seller profile by username.
9443
9452
  *
9444
- * Costs 10 credits.
9445
- *
9446
9453
  * @param username - The Depop seller username.
9447
9454
  * @param options - Optional parameters (market).
9448
9455
  * @returns Shop profile.
@@ -9456,8 +9463,6 @@ var DepopClient = class {
9456
9463
  /**
9457
9464
  * Get a Depop seller's products.
9458
9465
  *
9459
- * Costs 10 credits.
9460
- *
9461
9466
  * @param username - The Depop seller username.
9462
9467
  * @param options - Optional parameters (market, perPage, page).
9463
9468
  * @returns User products response with product cards and pagination meta.
@@ -9503,8 +9508,6 @@ var WallapopClient = class {
9503
9508
  * Needs a query, a `categoryId`, or both — unless `nextPage` is given, in
9504
9509
  * which case every other parameter is ignored.
9505
9510
  *
9506
- * Costs 5 credits.
9507
- *
9508
9511
  * @param query - Search text, e.g. "iphone 14" (optional with `categoryId` or `nextPage`).
9509
9512
  * @param options - Optional parameters (market, location/radius, category,
9510
9513
  * price, condition, brand/model/colour, cars filters, sort, cursor).
@@ -9546,8 +9549,6 @@ var WallapopClient = class {
9546
9549
  /**
9547
9550
  * Get a single listing's full detail.
9548
9551
  *
9549
- * Costs 5 credits.
9550
- *
9551
9552
  * @param itemId - Listing id (e.g. "nzxeknm5x562") or listing slug.
9552
9553
  * @param options - Optional parameters (market).
9553
9554
  * @returns Full listing detail with attributes, counters and location.
@@ -9563,8 +9564,6 @@ var WallapopClient = class {
9563
9564
  * Get a seller's profile with ratings, sales counters, response rate and
9564
9565
  * verifications.
9565
9566
  *
9566
- * Costs 5 credits.
9567
- *
9568
9567
  * @param userId - User id (e.g. "dqjwdd53wwzo") or profile slug (e.g. "alexc-25115753").
9569
9568
  * @param options - Optional parameters (market).
9570
9569
  * @returns User profile.
@@ -9579,8 +9578,6 @@ var WallapopClient = class {
9579
9578
  /**
9580
9579
  * Get a seller's live listings (40 per page).
9581
9580
  *
9582
- * Costs 5 credits.
9583
- *
9584
9581
  * @param userId - User id or profile slug.
9585
9582
  * @param options - Optional parameters (market, nextPage).
9586
9583
  * @returns The seller's listings and the next-page cursor.
@@ -9595,8 +9592,6 @@ var WallapopClient = class {
9595
9592
  /**
9596
9593
  * Get the reviews a seller received, newest first (40 per page).
9597
9594
  *
9598
- * Costs 5 credits.
9599
- *
9600
9595
  * @param userId - User id or profile slug.
9601
9596
  * @param options - Optional parameters (market, nextPage).
9602
9597
  * @returns Reviews and the next-page cursor.
@@ -9611,8 +9606,6 @@ var WallapopClient = class {
9611
9606
  /**
9612
9607
  * Get Wallapop's search-box suggestions for a partial query.
9613
9608
  *
9614
- * Costs 1 credit.
9615
- *
9616
9609
  * @param query - Partial search text, e.g. "bici".
9617
9610
  * @param options - Optional parameters (market).
9618
9611
  * @returns Autocomplete suggestions.
@@ -9625,8 +9618,6 @@ var WallapopClient = class {
9625
9618
  /**
9626
9619
  * Get the full category tree; ids are usable as the search `categoryId`.
9627
9620
  *
9628
- * Costs 1 credit.
9629
- *
9630
9621
  * @param options - Optional parameters (market — localises names).
9631
9622
  * @returns Category tree.
9632
9623
  */
@@ -9639,8 +9630,6 @@ var WallapopClient = class {
9639
9630
  * Get the search filters Wallapop offers for a category and/or query,
9640
9631
  * with their option ids.
9641
9632
  *
9642
- * Costs 2 credits.
9643
- *
9644
9633
  * @param options - Optional parameters (categoryId, query, market).
9645
9634
  * @returns Available filters.
9646
9635
  */
@@ -9657,8 +9646,6 @@ var WallapopClient = class {
9657
9646
  * Get a filter's long option list (brands, models) that Wallapop serves
9658
9647
  * separately — filters flagged `options_endpoint` in `listFilters`.
9659
9648
  *
9660
- * Costs 2 credits.
9661
- *
9662
9649
  * @param filterId - Filter id, e.g. "brand".
9663
9650
  * @param options - Optional parameters (categoryId, query, market).
9664
9651
  * @returns The filter's options.
@@ -9863,7 +9850,7 @@ var AskClient = class {
9863
9850
  /**
9864
9851
  * Ask ChatGPT a question and get the answer with its sources.
9865
9852
  *
9866
- * Costs 20 credits. Typical latency is 20-25s ungrounded, 30-70s with web search.
9853
+ * Typical latency is 20-25s ungrounded, 30-70s with web search.
9867
9854
  *
9868
9855
  * @param params - Ask parameters.
9869
9856
  * @param params.prompt - The prompt to send (max 4096 characters).
@@ -9908,8 +9895,6 @@ var BrandClient = class {
9908
9895
  /**
9909
9896
  * Analyse how a brand shows up in ChatGPT's answer to a prompt.
9910
9897
  *
9911
- * Costs 25 credits.
9912
- *
9913
9898
  * @param params - Brand-visibility parameters.
9914
9899
  * @param params.prompt - The prompt to send (max 4096 characters).
9915
9900
  * @param params.brand - The brand name to look for in the answer.
@@ -9960,8 +9945,6 @@ var ReferenceClient16 = class {
9960
9945
  /**
9961
9946
  * Get the models chatgpt.com currently offers.
9962
9947
  *
9963
- * Costs 1 credit.
9964
- *
9965
9948
  * @param params - Optional parameters.
9966
9949
  * @param params.country - ISO-3166 alpha-2 egress country (default: "US").
9967
9950
  * @returns The available models.
@@ -10311,6 +10294,7 @@ exports.BingMediaClient = MediaClient3;
10311
10294
  exports.BingNewsClient = NewsClient2;
10312
10295
  exports.BingReferenceClient = ReferenceClient8;
10313
10296
  exports.BingSearchClient = SearchClient11;
10297
+ exports.BlockedError = BlockedError;
10314
10298
  exports.ChatGPTAskClient = AskClient;
10315
10299
  exports.ChatGPTBrandClient = BrandClient;
10316
10300
  exports.ChatGPTClient = ChatGPTClient;