Skip to content

Commit 39bb3ca

Browse files
committed
Fix the live check: read prices with .get() and move the CLI block to 0.4.0
B0CRMZHDG8 is out of stock, so the API omits final_price, initial_price, buybox_prices and availability and blocks 1 and 4 raised KeyError. CLI 0.4.0 removed pipeline types; use pipelines run <dataset_id> collect_by_url and bump both workflow pins to 0.4.0.
1 parent 237dd33 commit 39bb3ca

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎.github/workflows/live.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: Install the package and the Bright Data CLI
7171
run: |
7272
pip install -e .
73-
npm i -g @brightdata/cli@0.3.4 # pinned: this job holds the API secret
73+
npm i -g @brightdata/cli@0.4.0 # pinned: this job holds the API secret
7474
7575
- name: Do the README's links still resolve?
7676
run: |
@@ -310,7 +310,7 @@ jobs:
310310
- name: Install the package and, for CLI blocks, the Bright Data CLI
311311
run: |
312312
pip install -e .
313-
if [ "${{ matrix.lang }}" = "bash" ]; then npm i -g @brightdata/cli@0.3.4; fi
313+
if [ "${{ matrix.lang }}" = "bash" ]; then npm i -g @brightdata/cli@0.4.0; fi
314314
- name: Run block ${{ matrix.n }} exactly as the README shows it
315315
env:
316316
N: ${{ matrix.n }}

‎README.md‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ from brightdata import SyncBrightDataClient
4646
with SyncBrightDataClient(auto_create_zones=False) as client:
4747
product = client.scrape.amazon.products("https://www.amazon.com/dp/B0CRMZHDG8").data
4848
print(product["title"])
49-
print(product["final_price"], product["currency"], "|", product["rating"], "stars |",
49+
print(product.get("final_price"), product["currency"], "|", product["rating"], "stars |",
5050
product["reviews_count"], "reviews")
5151
```
5252

@@ -65,6 +65,11 @@ never touches, and zone creation fails on accounts without a payment method
6565

6666
`products` takes a URL, not an ASIN, so write an ASIN as a `/dp/` URL as above.
6767

68+
Read prices with `.get()`. An out-of-stock product comes back with
69+
`is_available` set to `false` and no `final_price`, `initial_price`,
70+
`buybox_prices` or `availability` at all, so `product["final_price"]` raises
71+
`KeyError`.
72+
6873
## Or run it as a command
6974

7075
The command in this repo does the same for several ASINs and writes one JSON
@@ -184,7 +189,7 @@ with SyncBrightDataClient(auto_create_zones=False) as client:
184189
])
185190
for result in results:
186191
row = result.data
187-
print(row["asin"], "|", row["brand"], "|", row["final_price"], row["currency"])
192+
print(row["asin"], "|", row["brand"], "|", row.get("final_price"), row["currency"])
188193
```
189194

190195
```
@@ -436,12 +441,16 @@ once, or use `bdata login --device` over SSH and in CI:
436441

437442
```bash
438443
npx -p @brightdata/cli bdata login
439-
npx -p @brightdata/cli bdata pipelines amazon_product "https://www.amazon.com/dp/B0CRMZHDG8"
444+
npx -p @brightdata/cli bdata pipelines run gd_l7q7dkf244hwjntr0 collect_by_url "https://www.amazon.com/dp/B0CRMZHDG8"
440445
```
441446

442-
`bdata pipelines list` prints every type. The Amazon ones are `amazon_product`,
443-
`amazon_product_reviews` and `amazon_product_search`. Each takes URLs, prints
444-
JSON, and costs one credit per record.
447+
This is the CLI 0.4.0 syntax; the older `bdata pipelines amazon_product` form
448+
was removed in that release. `bdata pipelines search amazon` finds the scraper
449+
ids. The Amazon ones are `gd_l7q7dkf244hwjntr0` (products),
450+
`gd_le8e811kzy4ggddlq` (reviews) and `gd_lwdb4vjm1ehb499uxs` (search), all with
451+
the `collect_by_url` method. `bdata pipelines info <id> collect_by_url` lists a
452+
scraper's input fields. Each takes URLs, prints JSON, and costs one credit per
453+
record.
445454

446455
`npx skills add brightdata/skills` teaches Claude Code, Cursor and Codex these
447456
commands and the docs, so plain language works afterwards. Full guide:

0 commit comments

Comments
 (0)