decodo-sdk 2.3.0__tar.gz → 2.4.0__tar.gz
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.
- {decodo_sdk-2.3.0/src/decodo_sdk.egg-info → decodo_sdk-2.4.0}/PKG-INFO +209 -84
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/README.md +208 -83
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/pyproject.toml +1 -1
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/__init__.py +28 -0
- decodo_sdk-2.4.0/src/decodo/api/web_scraping_api.py +229 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/client.py +1 -1
- decodo_sdk-2.4.0/src/decodo/errors.py +88 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/generated/decodo.ir.json +927 -1
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/bundled_schema.py +6 -1
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/remote_schema.py +5 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/types.py +30 -3
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/types/__init__.py +22 -0
- decodo_sdk-2.4.0/src/decodo/types/data_api.py +199 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0/src/decodo_sdk.egg-info}/PKG-INFO +209 -84
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo_sdk.egg-info/SOURCES.txt +2 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/tests/test_client.py +29 -0
- decodo_sdk-2.4.0/tests/test_data_api.py +412 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/tests/test_web_scraping_api.py +3 -0
- decodo_sdk-2.3.0/src/decodo/api/web_scraping_api.py +0 -91
- decodo_sdk-2.3.0/src/decodo/errors.py +0 -36
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/LICENSE +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/setup.cfg +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/api/__init__.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/__init__.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/codegen.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/web_scraping_api/__init__.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/web_scraping_api/generate_parameters.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/web_scraping_api/generate_targets.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/web_scraping_api/shared.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/codegen/web_scraping_api/types.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/generated/__init__.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/generated/parameters.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/generated/targets.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/http.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/py.typed +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/__init__.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/build_target_meta.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/constants.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/expand_path.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/schema/resolve_latest_ir.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/targets.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/types/requests.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo/types/responses.py +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo_sdk.egg-info/dependency_links.txt +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo_sdk.egg-info/requires.txt +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/src/decodo_sdk.egg-info/top_level.txt +0 -0
- {decodo_sdk-2.3.0 → decodo_sdk-2.4.0}/tests/test_http.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: decodo-sdk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Official Python SDK for the Decodo APIs
|
|
5
5
|
Author: Decodo
|
|
6
6
|
License: MIT License
|
|
@@ -105,7 +105,7 @@ pip install decodo-sdk
|
|
|
105
105
|
touch main.py
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
Copy your Web Data API key from your Web Data API subscription on the [Decodo dashboard](https://dashboard.decodo.com/web-data/playground). Older plans only have a basic authentication token, which you can pass as `token` instead (see [Configuration](#configuration)).
|
|
109
109
|
|
|
110
110
|
Every target has a corresponding parameter class. Import the one you need, fill in its fields, and pass it to `scrape()`:
|
|
111
111
|
|
|
@@ -121,7 +121,7 @@ from decodo import (
|
|
|
121
121
|
client = DecodoClient(
|
|
122
122
|
DecodoConfig(
|
|
123
123
|
web_scraping_api=WebScrapingApiConfig(
|
|
124
|
-
|
|
124
|
+
api_key="<api_key>",
|
|
125
125
|
),
|
|
126
126
|
)
|
|
127
127
|
)
|
|
@@ -285,17 +285,31 @@ from decodo import (
|
|
|
285
285
|
client = DecodoClient(
|
|
286
286
|
DecodoConfig(
|
|
287
287
|
web_scraping_api=WebScrapingApiConfig(
|
|
288
|
-
|
|
288
|
+
api_key="<api_key>",
|
|
289
289
|
),
|
|
290
290
|
timeout_ms=120_000, # optional, request timeout in ms (default: 180000)
|
|
291
291
|
)
|
|
292
292
|
)
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
Pass either `api_key` or `token`, not both. The client raises `ValueError` if you set both.
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
# Basic auth token (older plans)
|
|
299
|
+
client = DecodoClient(
|
|
300
|
+
DecodoConfig(
|
|
301
|
+
web_scraping_api=WebScrapingApiConfig(
|
|
302
|
+
token="<basic_auth_token>",
|
|
303
|
+
),
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
| Parameter | Description |
|
|
309
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
310
|
+
| `api_key` | Web Data API key. Recommended |
|
|
311
|
+
| `token` | Web Scraping API basic auth token for older plans, the base64-encoded `user:password` string from the Decodo dashboard. Use it instead of `api_key` |
|
|
312
|
+
| `timeout_ms` | Request timeout in milliseconds (default: 180000) |
|
|
299
313
|
|
|
300
314
|
## Web Scraping API
|
|
301
315
|
|
|
@@ -318,7 +332,7 @@ from decodo import (
|
|
|
318
332
|
client = DecodoClient(
|
|
319
333
|
DecodoConfig(
|
|
320
334
|
web_scraping_api=WebScrapingApiConfig(
|
|
321
|
-
|
|
335
|
+
api_key="<api_key>",
|
|
322
336
|
),
|
|
323
337
|
)
|
|
324
338
|
)
|
|
@@ -352,7 +366,7 @@ from decodo import (
|
|
|
352
366
|
client = DecodoClient(
|
|
353
367
|
DecodoConfig(
|
|
354
368
|
web_scraping_api=WebScrapingApiConfig(
|
|
355
|
-
|
|
369
|
+
api_key="<api_key>",
|
|
356
370
|
),
|
|
357
371
|
)
|
|
358
372
|
)
|
|
@@ -405,7 +419,7 @@ from decodo import (
|
|
|
405
419
|
client = DecodoClient(
|
|
406
420
|
DecodoConfig(
|
|
407
421
|
web_scraping_api=WebScrapingApiConfig(
|
|
408
|
-
|
|
422
|
+
api_key="<api_key>",
|
|
409
423
|
),
|
|
410
424
|
)
|
|
411
425
|
)
|
|
@@ -439,6 +453,116 @@ for task in batch["queries"]:
|
|
|
439
453
|
print(result)
|
|
440
454
|
```
|
|
441
455
|
|
|
456
|
+
## Data API: search, map and crawl
|
|
457
|
+
|
|
458
|
+
These endpoints are served by the Data API at `data.decodo.com` and need an `api_key`. Calling them on a client configured with a basic auth `token` raises `ValueError` saying an API key is required. They live on the same `client.web_scraping_api` namespace.
|
|
459
|
+
|
|
460
|
+
Parameters are plain dictionaries. The `SearchRequest`, `MapRequest` and `CrawlRequest` types are `TypedDict`s you can use for editor completion; they are always importable and need no code generation. Bodies are validated against the bundled schema before the request is sent, like `scrape`.
|
|
461
|
+
|
|
462
|
+
### Search
|
|
463
|
+
|
|
464
|
+
Runs a web search and returns the parsed result document:
|
|
465
|
+
|
|
466
|
+
```python
|
|
467
|
+
from decodo import DecodoClient, DecodoConfig, SearchRequest, WebScrapingApiConfig
|
|
468
|
+
|
|
469
|
+
client = DecodoClient(
|
|
470
|
+
DecodoConfig(
|
|
471
|
+
web_scraping_api=WebScrapingApiConfig(
|
|
472
|
+
api_key="<api_key>",
|
|
473
|
+
),
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
result = client.web_scraping_api.search(
|
|
478
|
+
SearchRequest(query="coffee shops", geo="United States", page=1)
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
for item in result.get("organic", []):
|
|
482
|
+
print(item["rank"], item["title"], item["link"])
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
A search that ran but could not be scraped still answers with HTTP 200 and `status: "failed"` plus a `message`, so check `result["status"]` before reading the fields.
|
|
486
|
+
|
|
487
|
+
### Map
|
|
488
|
+
|
|
489
|
+
Discovers the links on a site, from its pages and sitemap:
|
|
490
|
+
|
|
491
|
+
```python
|
|
492
|
+
from decodo import DecodoClient, DecodoConfig, MapRequest, WebScrapingApiConfig
|
|
493
|
+
|
|
494
|
+
client = DecodoClient(
|
|
495
|
+
DecodoConfig(
|
|
496
|
+
web_scraping_api=WebScrapingApiConfig(
|
|
497
|
+
api_key="<api_key>",
|
|
498
|
+
),
|
|
499
|
+
)
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
result = client.web_scraping_api.map(
|
|
503
|
+
MapRequest(url="https://www.example.com", limit=100, sitemap="include")
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
for link in result["results"][0]["content"]["links"]:
|
|
507
|
+
print(link["url"])
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### Crawl
|
|
511
|
+
|
|
512
|
+
`crawl` starts a crawl, waits for it to finish and returns every page with its content:
|
|
513
|
+
|
|
514
|
+
```python
|
|
515
|
+
from decodo import (
|
|
516
|
+
CrawlError,
|
|
517
|
+
CrawlInterruptedError,
|
|
518
|
+
CrawlRequest,
|
|
519
|
+
CrawlTimeoutError,
|
|
520
|
+
DecodoClient,
|
|
521
|
+
DecodoConfig,
|
|
522
|
+
WebScrapingApiConfig,
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
client = DecodoClient(
|
|
526
|
+
DecodoConfig(
|
|
527
|
+
web_scraping_api=WebScrapingApiConfig(
|
|
528
|
+
api_key="<api_key>",
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
try:
|
|
534
|
+
pages = client.web_scraping_api.crawl(
|
|
535
|
+
CrawlRequest(url="https://www.example.com", limit=20, max_depth=2),
|
|
536
|
+
poll_interval=5,
|
|
537
|
+
timeout=600,
|
|
538
|
+
)
|
|
539
|
+
except CrawlTimeoutError as err:
|
|
540
|
+
print(f"Still running, fetch it later with get_crawl_results({err.crawl_id!r})")
|
|
541
|
+
except CrawlError as err:
|
|
542
|
+
print(f"Crawl {err.crawl_id} ended {err.status}: {err.reason}")
|
|
543
|
+
else:
|
|
544
|
+
for page in pages:
|
|
545
|
+
print(page["url"], page["status"], page.get("content", "")[:80])
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
A crawl that stops early because of `max_duration` or a vendor limit ends with status `truncated`; `crawl` returns the pages it did collect. Pages are returned as the API lists them, each with its `status` (`pending`, `done` or `faulted`) and, when the fetch failed, a `content_error` instead of `content`.
|
|
549
|
+
|
|
550
|
+
The lower-level methods let you drive a crawl yourself, for example to start it in one process and collect it in another:
|
|
551
|
+
|
|
552
|
+
```python
|
|
553
|
+
started = client.web_scraping_api.start_crawl(CrawlRequest(url="https://www.example.com"))
|
|
554
|
+
crawl_id = started["crawl_id"]
|
|
555
|
+
|
|
556
|
+
status = client.web_scraping_api.get_crawl_status(crawl_id)
|
|
557
|
+
print(status["status"], status["completed"], status["in_flight"])
|
|
558
|
+
|
|
559
|
+
pages = client.web_scraping_api.get_crawl_results(crawl_id)
|
|
560
|
+
|
|
561
|
+
client.web_scraping_api.cancel_crawl(crawl_id)
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
`get_crawl_status` returns `pending`, `done`, `faulted`, `cancelled` or `truncated`, with a `reason` when the crawl stopped early.
|
|
565
|
+
|
|
442
566
|
## Targets and parameter classes
|
|
443
567
|
|
|
444
568
|
Every target in the `Target` enum has a matching parameter class. The name of the class is the enum member name followed by `Params`:
|
|
@@ -468,85 +592,84 @@ Each target accepts one primary input parameter (`url`, `query`, `product_id`, o
|
|
|
468
592
|
|
|
469
593
|
### Search engines
|
|
470
594
|
|
|
471
|
-
| Target
|
|
472
|
-
|
|
|
473
|
-
| `Target.GoogleSearch`
|
|
474
|
-
| `Target.GoogleMaps`
|
|
475
|
-
| `Target.GoogleShoppingSearch`
|
|
476
|
-
| `Target.GoogleShoppingProduct` | `GoogleShoppingProductParams` | Google Shopping product page
|
|
477
|
-
| `Target.GoogleSuggest`
|
|
478
|
-
| `Target.GoogleLens`
|
|
479
|
-
| `Target.GoogleTravelHotels`
|
|
480
|
-
| `Target.GoogleTrendsExplore`
|
|
481
|
-
| `Target.GoogleAds`
|
|
482
|
-
| `Target.BingSearch`
|
|
483
|
-
| `Target.Bing`
|
|
595
|
+
| Target | Parameter class | Description | Example input |
|
|
596
|
+
| ------------------------------ | ----------------------------- | --------------------------------- | ---------------------------------------- |
|
|
597
|
+
| `Target.GoogleSearch` | `GoogleSearchParams` | Google Search results for a query | `query="coffee shops"` |
|
|
598
|
+
| `Target.GoogleMaps` | `GoogleMapsParams` | Google Maps search results | `query="coffee shops brooklyn"` |
|
|
599
|
+
| `Target.GoogleShoppingSearch` | `GoogleShoppingSearchParams` | Google Shopping search results | `query="laptop"` |
|
|
600
|
+
| `Target.GoogleShoppingProduct` | `GoogleShoppingProductParams` | Google Shopping product page | `query="laptop"` |
|
|
601
|
+
| `Target.GoogleSuggest` | `GoogleSuggestParams` | Google Autocomplete suggestions | `query="coffee"` |
|
|
602
|
+
| `Target.GoogleLens` | `GoogleLensParams` | Google Lens reverse image search | `query="https://example.com/cat.jpg"` |
|
|
603
|
+
| `Target.GoogleTravelHotels` | `GoogleTravelHotelsParams` | Google Travel hotel listings | `query="hotels in paris"` |
|
|
604
|
+
| `Target.GoogleTrendsExplore` | `GoogleTrendsExploreParams` | Google Trends explore data | `query="coffee"` |
|
|
605
|
+
| `Target.GoogleAds` | `GoogleAdsParams` | Google Ads results for a query | `query="laptop"` |
|
|
606
|
+
| `Target.BingSearch` | `BingSearchParams` | Bing Search results | `query="electric vehicles"` |
|
|
607
|
+
| `Target.Bing` | `BingParams` | Raw Bing URL scraping | `url="https://bing.com/search?q=laptop"` |
|
|
484
608
|
|
|
485
609
|
### eCommerce
|
|
486
610
|
|
|
487
|
-
| Target
|
|
488
|
-
|
|
|
489
|
-
| `Target.AmazonProduct`
|
|
490
|
-
| `Target.AmazonSearch`
|
|
491
|
-
| `Target.AmazonPricing`
|
|
492
|
-
| `Target.AmazonSellers`
|
|
493
|
-
| `Target.AmazonBestsellers` | `AmazonBestsellersParams` | Amazon bestsellers by category
|
|
494
|
-
| `Target.WalmartProduct`
|
|
495
|
-
| `Target.WalmartSearch`
|
|
496
|
-
| `Target.Walmart`
|
|
497
|
-
| `Target.TargetProduct`
|
|
498
|
-
| `Target.TargetSearch`
|
|
499
|
-
| `Target.Target`
|
|
500
|
-
| `Target.LowesSearch`
|
|
501
|
-
| `Target.Ecommerce`
|
|
611
|
+
| Target | Parameter class | Description | Example input |
|
|
612
|
+
| -------------------------- | ------------------------- | ------------------------------------- | ------------------------------------------ |
|
|
613
|
+
| `Target.AmazonProduct` | `AmazonProductParams` | Amazon product detail page by ASIN | `query="B09H74FXNW"` |
|
|
614
|
+
| `Target.AmazonSearch` | `AmazonSearchParams` | Amazon search results | `query="laptop"` |
|
|
615
|
+
| `Target.AmazonPricing` | `AmazonPricingParams` | Amazon pricing and offers | `query="B09H74FXNW"` |
|
|
616
|
+
| `Target.AmazonSellers` | `AmazonSellersParams` | Amazon seller listings | `query="B09H74FXNW"` |
|
|
617
|
+
| `Target.AmazonBestsellers` | `AmazonBestsellersParams` | Amazon bestsellers by category | `query="electronics"` |
|
|
618
|
+
| `Target.WalmartProduct` | `WalmartProductParams` | Walmart product page by product ID | `product_id="15296401808"` |
|
|
619
|
+
| `Target.WalmartSearch` | `WalmartSearchParams` | Walmart search results | `query="laptop"` |
|
|
620
|
+
| `Target.Walmart` | `WalmartParams` | Raw Walmart URL scraping | `url="https://walmart.com/ip/15296401808"` |
|
|
621
|
+
| `Target.TargetProduct` | `TargetProductParams` | Target.com product page by product ID | `product_id="92186007"` |
|
|
622
|
+
| `Target.TargetSearch` | `TargetSearchParams` | Target.com search results | `query="laptop"` |
|
|
623
|
+
| `Target.Target` | `TargetStoreParams` | Raw Target.com URL scraping | `url="https://target.com/p/-/A-92186007"` |
|
|
624
|
+
| `Target.LowesSearch` | `LowesSearchParams` | Lowe's search results | `query="drill"` |
|
|
625
|
+
| `Target.Ecommerce` | `EcommerceParams` | Generic eCommerce page with parser | `url="https://example.com/product/123"` |
|
|
502
626
|
|
|
503
627
|
### Social media
|
|
504
628
|
|
|
505
|
-
| Target
|
|
506
|
-
|
|
|
507
|
-
| `Target.RedditPost`
|
|
508
|
-
| `Target.RedditSubreddit`
|
|
509
|
-
| `Target.RedditUser`
|
|
510
|
-
| `Target.YoutubeVideo`
|
|
511
|
-
| `Target.YoutubeSearch`
|
|
512
|
-
| `Target.YoutubeSearchMax`
|
|
513
|
-
| `Target.YoutubeMetadata`
|
|
514
|
-
| `Target.YoutubeTranscript`
|
|
515
|
-
| `Target.YoutubeSubtitles`
|
|
516
|
-
| `Target.YoutubeChannel`
|
|
517
|
-
| `Target.TiktokPost`
|
|
518
|
-
| `Target.TiktokShopSearch`
|
|
519
|
-
| `Target.TiktokShopProduct`
|
|
520
|
-
| `Target.Tiktok`
|
|
521
|
-
| `Target.InstagramGraphqlProfile` | `InstagramGraphqlProfileParams` | Instagram profile via GraphQL
|
|
629
|
+
| Target | Parameter class | Description | Example input |
|
|
630
|
+
| -------------------------------- | ------------------------------- | -------------------------------------- | --------------------------------------------- |
|
|
631
|
+
| `Target.RedditPost` | `RedditPostParams` | Reddit post by URL | `url="https://reddit.com/r/nba/comments/..."` |
|
|
632
|
+
| `Target.RedditSubreddit` | `RedditSubredditParams` | Reddit subreddit by URL | `url="https://reddit.com/r/nba/"` |
|
|
633
|
+
| `Target.RedditUser` | `RedditUserParams` | Reddit user profile by URL | `url="https://reddit.com/user/example/"` |
|
|
634
|
+
| `Target.YoutubeVideo` | `YoutubeVideoParams` | YouTube video by ID | `query="dFu9aKJoqGg"` |
|
|
635
|
+
| `Target.YoutubeSearch` | `YoutubeSearchParams` | YouTube search results | `query="ambient music"` |
|
|
636
|
+
| `Target.YoutubeSearchMax` | `YoutubeSearchMaxParams` | YouTube search results (extended) | `query="ambient music"` |
|
|
637
|
+
| `Target.YoutubeMetadata` | `YoutubeMetadataParams` | YouTube video metadata by ID | `query="dFu9aKJoqGg"` |
|
|
638
|
+
| `Target.YoutubeTranscript` | `YoutubeTranscriptParams` | YouTube video transcript by ID | `query="dFu9aKJoqGg"` |
|
|
639
|
+
| `Target.YoutubeSubtitles` | `YoutubeSubtitlesParams` | YouTube video subtitles by ID | `query="dFu9aKJoqGg"` |
|
|
640
|
+
| `Target.YoutubeChannel` | `YoutubeChannelParams` | YouTube channel by handle or ID | `query="@decodo_official"` |
|
|
641
|
+
| `Target.TiktokPost` | `TiktokPostParams` | TikTok post by URL | `url="https://www.tiktok.com/@nba/video/..."` |
|
|
642
|
+
| `Target.TiktokShopSearch` | `TiktokShopSearchParams` | TikTok Shop search results | `query="wireless earbuds"` |
|
|
643
|
+
| `Target.TiktokShopProduct` | `TiktokShopProductParams` | TikTok Shop product page by product ID | `product_id="7100000000000000000"` |
|
|
644
|
+
| `Target.Tiktok` | `TiktokParams` | Raw TikTok URL scraping | `url="https://www.tiktok.com/@nba"` |
|
|
645
|
+
| `Target.InstagramGraphqlProfile` | `InstagramGraphqlProfileParams` | Instagram profile via GraphQL | `query="nba"` |
|
|
522
646
|
|
|
523
647
|
### AI tools
|
|
524
648
|
|
|
525
|
-
| Target
|
|
526
|
-
|
|
|
527
|
-
| `Target.Chatgpt`
|
|
528
|
-
| `Target.Perplexity`
|
|
529
|
-
| `Target.Gemini`
|
|
530
|
-
| `Target.GoogleAiMode` | `GoogleAiModeParams` | Google AI Mode response
|
|
649
|
+
| Target | Parameter class | Description | Example input |
|
|
650
|
+
| --------------------- | -------------------- | -------------------------------- | --------------------------------------------- |
|
|
651
|
+
| `Target.Chatgpt` | `ChatgptParams` | ChatGPT response for a prompt | `prompt="What are the top three dog breeds?"` |
|
|
652
|
+
| `Target.Perplexity` | `PerplexityParams` | Perplexity response for a prompt | `prompt="What causes seasonal allergies?"` |
|
|
653
|
+
| `Target.Gemini` | `GeminiParams` | Gemini response for a prompt | `prompt="What are the top three dog breeds?"` |
|
|
654
|
+
| `Target.GoogleAiMode` | `GoogleAiModeParams` | Google AI Mode response | `query="What are the top three dog breeds?"` |
|
|
531
655
|
|
|
532
656
|
### Other
|
|
533
657
|
|
|
534
|
-
| Target
|
|
535
|
-
|
|
|
536
|
-
| `Target.Bbb`
|
|
537
|
-
| `Target.Autotrader`
|
|
538
|
-
| `Target.Mobile`
|
|
539
|
-
| `Target.Airbnb`
|
|
540
|
-
| `Target.AppleAppStore` | `AppleAppStoreParams` | Apple App Store app by URL
|
|
658
|
+
| Target | Parameter class | Description | Example input |
|
|
659
|
+
| ---------------------- | --------------------- | ------------------------------------- | ------------------------------------------------ |
|
|
660
|
+
| `Target.Bbb` | `BbbParams` | Better Business Bureau listing by URL | `url="https://bbb.org/us/ny/new-york/..."` |
|
|
661
|
+
| `Target.Autotrader` | `AutotraderParams` | Autotrader listing by URL | `url="https://autotrader.com/cars-for-sale/..."` |
|
|
662
|
+
| `Target.Mobile` | `MobileParams` | Mobile.de listing by URL | `url="https://mobile.de/auto/..."` |
|
|
663
|
+
| `Target.Airbnb` | `AirbnbParams` | Airbnb listing by URL | `url="https://airbnb.com/rooms/12345"` |
|
|
664
|
+
| `Target.AppleAppStore` | `AppleAppStoreParams` | Apple App Store app by URL | `url="https://apps.apple.com/app/id12345"` |
|
|
541
665
|
|
|
542
666
|
### Universal scraping
|
|
543
667
|
|
|
544
|
-
| Target
|
|
545
|
-
|
|
|
546
|
-
| `Target.Universal` | `UniversalParams` | Any URL via the universal scraper | `url="https://example.com"`
|
|
547
|
-
| `Target.Google`
|
|
548
|
-
| `Target.Amazon`
|
|
549
|
-
|
|
668
|
+
| Target | Parameter class | Description | Example input |
|
|
669
|
+
| ------------------ | ----------------- | --------------------------------- | ------------------------------------------ |
|
|
670
|
+
| `Target.Universal` | `UniversalParams` | Any URL via the universal scraper | `url="https://example.com"` |
|
|
671
|
+
| `Target.Google` | `GoogleParams` | Raw Google URL scraping | `url="https://google.com/search?q=laptop"` |
|
|
672
|
+
| `Target.Amazon` | `AmazonParams` | Raw Amazon URL scraping | `url="https://amazon.com/dp/B09H74FXNW"` |
|
|
550
673
|
|
|
551
674
|
> `Target.UniversalEcommerce` isn't listed above because it doesn't accept a primary input parameter like `url`, `query`, `product_id`, or `prompt`. Its parameter class `UniversalEcommerceParams` only accepts optional configuration fields such as `callback_url`.
|
|
552
675
|
|
|
@@ -577,7 +700,7 @@ from decodo import (
|
|
|
577
700
|
client = DecodoClient(
|
|
578
701
|
DecodoConfig(
|
|
579
702
|
web_scraping_api=WebScrapingApiConfig(
|
|
580
|
-
|
|
703
|
+
api_key="<api_key>",
|
|
581
704
|
),
|
|
582
705
|
)
|
|
583
706
|
)
|
|
@@ -603,7 +726,7 @@ try:
|
|
|
603
726
|
except AuthenticationError:
|
|
604
727
|
# Handle authentication failures.
|
|
605
728
|
raise SystemExit(
|
|
606
|
-
"Invalid token. Check
|
|
729
|
+
"Invalid API key or token. Check your credentials in the dashboard."
|
|
607
730
|
)
|
|
608
731
|
|
|
609
732
|
except RateLimitError:
|
|
@@ -629,13 +752,15 @@ except DecodoError as err:
|
|
|
629
752
|
|
|
630
753
|
The `["results"]["results"]` nesting above is the shape returned when `parse=True`. Without it, `content` holds the raw page instead.
|
|
631
754
|
|
|
632
|
-
| Error
|
|
633
|
-
|
|
|
634
|
-
| `AuthenticationError` | The API returns `401` or `403`
|
|
635
|
-
| `RateLimitError`
|
|
636
|
-
| `ValidationError`
|
|
637
|
-
| `TimeoutError`
|
|
638
|
-
| `
|
|
755
|
+
| Error | Raised when | Useful attributes |
|
|
756
|
+
| --------------------- | ------------------------------------------------------------------------------------ | ------------------------------ |
|
|
757
|
+
| `AuthenticationError` | The API returns `401` or `403` | `status_code` |
|
|
758
|
+
| `RateLimitError` | The API returns `429` | `status_code` |
|
|
759
|
+
| `ValidationError` | The payload fails local schema validation, or the API returns `422` | `errors`, `status_code` |
|
|
760
|
+
| `TimeoutError` | The request exceeds `timeout_ms` | none |
|
|
761
|
+
| `CrawlTimeoutError` | `crawl()` exceeds its `timeout`. Subclass of `TimeoutError`; the crawl keeps running | `crawl_id` |
|
|
762
|
+
| `CrawlError` | `crawl()` ends `faulted` or `cancelled`. Subclass of `DecodoError` | `crawl_id`, `status`, `reason` |
|
|
763
|
+
| `DecodoError` | Any other unsuccessful response. Base class for the three errors above | `status_code`, `api_status` |
|
|
639
764
|
|
|
640
765
|
Two things to keep in mind:
|
|
641
766
|
|