@decodo/sdk-ts 2.6.1 → 3.0.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/README.md CHANGED
@@ -469,8 +469,14 @@ const { status, pages } = await client.webScrapingApi.crawl(
469
469
  { url: 'https://example.com', limit: 50, output: 'markdown' },
470
470
  { pollInterval: 5_000, timeout: 600_000 },
471
471
  );
472
+
473
+ if (status.status !== 'done') {
474
+ console.warn(`Crawl ended ${status.status}; ${pages.length} pages collected`);
475
+ }
472
476
  ```
473
477
 
478
+ `crawl` doesn't throw when a crawl ends `faulted`, `cancelled` or `truncated`. It returns the pages collected so far, and `status` is the full crawl status object, so check `status.status` before relying on `pages`. If the crawl hasn't settled before `timeout`, `crawl` throws a `TimeoutError` and the crawl keeps running on the server; call `cancelCrawl` to stop it.
479
+
474
480
  To drive a crawl step by step, start it and poll separately for status and pages:
475
481
 
476
482
  ```typescript
@@ -481,6 +487,12 @@ console.log(progress.status); // 'pending' | 'done' | 'faulted' | 'cancelled' |
481
487
 
482
488
  const pages = await client.webScrapingApi.getCrawlResults(job.crawl_id);
483
489
 
490
+ const firstPage = await client.webScrapingApi.listCrawlPages(job.crawl_id);
491
+
492
+ if (firstPage.next) {
493
+ await client.webScrapingApi.listCrawlPages(job.crawl_id, { cursor: firstPage.next });
494
+ }
495
+
484
496
  await client.webScrapingApi.cancelCrawl(job.crawl_id);
485
497
  ```
486
498
 
@@ -490,35 +502,31 @@ Each target accepts one primary input parameter (`url`, `query`, `product_id`, o
490
502
 
491
503
  ### Search engines
492
504
 
493
- | Target | Description | Example |
494
- | ----------------------------- | --------------------------------- | --------------------------------------------------------------------- |
495
- | `Target.GoogleSearch` | Google Search results for a query | `{ target: Target.GoogleSearch, query: "coffee shops" }` |
496
- | `Target.GoogleMaps` | Google Maps search results | `{ target: Target.GoogleMaps, query: "coffee shops brooklyn" }` |
497
- | `Target.GoogleShoppingSearch` | Google Shopping search results | `{ target: Target.GoogleShoppingSearch, query: "laptop" }` |
498
- | `Target.GoogleSuggest` | Google Autocomplete suggestions | `{ target: Target.GoogleSuggest, query: "coffee" }` |
499
- | `Target.GoogleLens` | Google Lens reverse image search | `{ target: Target.GoogleLens, query: "https://example.com/cat.jpg" }` |
500
- | `Target.BingSearch` | Bing Search results | `{ target: Target.BingSearch, query: "electric vehicles" }` |
505
+ | Target | Description | Example |
506
+ | --------------------- | --------------------------------- | --------------------------------------------------------------------- |
507
+ | `Target.GoogleSearch` | Google Search results for a query | `{ target: Target.GoogleSearch, query: "coffee shops" }` |
508
+ | `Target.GoogleLens` | Google Lens reverse image search | `{ target: Target.GoogleLens, query: "https://example.com/cat.jpg" }` |
509
+ | `Target.BingSearch` | Bing Search results | `{ target: Target.BingSearch, query: "electric vehicles" }` |
501
510
 
502
511
  ### eCommerce
503
512
 
504
- | Target | Description | Example |
505
- | ----------------------- | ------------------------------------- | ---------------------------------------------------------------------- |
506
- | `Target.AmazonProduct` | Amazon product detail page by ASIN | `{ target: Target.AmazonProduct, query: "B09H74FXNW" }` |
507
- | `Target.AmazonSearch` | Amazon search results | `{ target: Target.AmazonSearch, query: "laptop" }` |
508
- | `Target.AmazonPricing` | Amazon pricing and offers | `{ target: Target.AmazonPricing, query: "B09H74FXNW" }` |
509
- | `Target.WalmartProduct` | Walmart product page by product ID | `{ target: Target.WalmartProduct, product_id: "15296401808" }` |
510
- | `Target.TargetProduct` | Target.com product page by product ID | `{ target: Target.TargetProduct, product_id: "92186007" }` |
511
- | `Target.Ecommerce` | Generic eCommerce page with parser | `{ target: Target.Ecommerce, url: "https://example.com/product/123" }` |
513
+ | Target | Description | Example |
514
+ | ----------------------- | ------------------------------------- | -------------------------------------------------------------- |
515
+ | `Target.AmazonProduct` | Amazon product detail page by ASIN | `{ target: Target.AmazonProduct, query: "B09H74FXNW" }` |
516
+ | `Target.AmazonSearch` | Amazon search results | `{ target: Target.AmazonSearch, query: "laptop" }` |
517
+ | `Target.AmazonPricing` | Amazon pricing and offers | `{ target: Target.AmazonPricing, query: "B09H74FXNW" }` |
518
+ | `Target.WalmartProduct` | Walmart product page by product ID | `{ target: Target.WalmartProduct, product_id: "15296401808" }` |
519
+ | `Target.TargetProduct` | Target.com product page by product ID | `{ target: Target.TargetProduct, product_id: "92186007" }` |
512
520
 
513
521
  ### Social media
514
522
 
515
- | Target | Description | Example |
516
- | ------------------------ | ----------------------- | ----------------------------------------------------------------------------- |
517
- | `Target.RedditPost` | Reddit post by URL | `{ target: Target.RedditPost, url: "https://reddit.com/r/nba/..." }` |
518
- | `Target.RedditSubreddit` | Reddit subreddit by URL | `{ target: Target.RedditSubreddit, url: "https://reddit.com/r/nba/" }` |
519
- | `Target.YoutubeVideo` | YouTube video by ID | `{ target: Target.YoutubeVideo, query: "dFu9aKJoqGg" }` |
520
- | `Target.YoutubeSearch` | YouTube search results | `{ target: Target.YoutubeSearch, query: "ambient music" }` |
521
- | `Target.TiktokPost` | TikTok post by URL | `{ target: Target.TiktokPost, url: "https://www.tiktok.com/@nba/video/..." }` |
523
+ | Target | Description | Example |
524
+ | ------------------------ | ---------------------------- | ----------------------------------------------------------------------------- |
525
+ | `Target.RedditPost` | Reddit post by URL | `{ target: Target.RedditPost, url: "https://reddit.com/r/nba/..." }` |
526
+ | `Target.RedditSubreddit` | Reddit subreddit by URL | `{ target: Target.RedditSubreddit, url: "https://reddit.com/r/nba/" }` |
527
+ | `Target.YoutubeMetadata` | YouTube video metadata by ID | `{ target: Target.YoutubeMetadata, query: "dFu9aKJoqGg" }` |
528
+ | `Target.YoutubeSearch` | YouTube search results | `{ target: Target.YoutubeSearch, query: "ambient music" }` |
529
+ | `Target.TiktokPost` | TikTok post by URL | `{ target: Target.TiktokPost, url: "https://www.tiktok.com/@nba/video/..." }` |
522
530
 
523
531
  ### AI tools
524
532
 
@@ -537,8 +545,6 @@ Each target accepts one primary input parameter (`url`, `query`, `product_id`, o
537
545
  | `Target.Google` | Raw Google URL scraping | `{ target: Target.Google, url: "https://google.com/search?q=laptop" }` |
538
546
  | `Target.Amazon` | Raw Amazon URL scraping | `{ target: Target.Amazon, url: "https://amazon.com/dp/B09H74FXNW" }` |
539
547
 
540
- > `Target.UniversalEcommerce` isn't listed above because it doesn't accept a primary input parameter like `url`, `query`, `product_id`, or `prompt`. It only accepts optional configuration fields such as `callback_url`.
541
-
542
548
  For the full target list and parameter details, see the API documentation:
543
549
 
544
550
  - [Target list](https://help.decodo.com/docs/web-scraping-api-targets)