Skip to content

Scrape Amazon Prices with Python: ASIN-to-CSV Workflow

Amazon product pages are built for shoppers, not for tidy data collection. Prices sit inside JavaScript-heavy layouts, the same product can show different amounts by region or device, and automated requests often meet CAPTCHAs or IP blocks. This guide shows a practical Python path: send product-page requests through a scraping API that handles rendering and proxies, target a small set of CSS selectors for name and price, then collect the results in a DataFrame and save them as a CSV. The workflow is intentionally narrow so you can verify each step before adding more ASINs or fields.

Why direct requests fall short on Amazon

A plain HTTP request to an Amazon product URL can return a CAPTCHA page, a blocked response, or HTML that is missing price elements because the page relies on JavaScript. Amazon also applies region and device variation, so the same ASIN may not show the same price everywhere. A scraping API is useful here because it can render JavaScript, rotate proxies, and retry failed connections. That does not remove the need to check your selectors: Amazon changes markup, and a selector that worked last month can return nothing today. Treat selector maintenance as part of the workflow, not a one-time setup.

Set up Python, the client, and your API key

Use Python 3.6 or newer. Install the scraping client and pandas, the library used to shape results into a table. The client wraps HTTP requests and exposes parameters for rendering, proxies, and extraction rules. You will also need an API key from your account dashboard; keep it out of shared code and load it from an environment variable in real projects. The example below uses a placeholder so the script stays portable.

Selector field map: what each rule controls

The extraction rules use three CSS selectors. The container limits where the parser looks, the title selector captures the product name, and the price selector captures the displayed amount. If the container is wrong, the parser may miss the price even when the page loaded correctly. If the price selector is stale, the name may still come through while the price column is empty. Use the browser inspector on a live product page to confirm each selector before running a batch.

Loop over ASINs and build the CSV

The script defines a function that accepts a list of ASINs. For each ASIN it requests the product page, passes the extraction rules and JavaScript scenario, and retries up to two times if the connection fails. The response is converted to JSON, the Products list becomes a DataFrame, and each DataFrame is appended to a master list. After the loop, the frames are concatenated and written to Amazon_Prices.csv. A status-code print helps you distinguish a successful extraction from a blocked or failed request.

Anti-bot and localization controls

If a request is blocked or the price looks wrong for your target market, add parameters rather than guessing. Premium proxies raise connection quality, a country code forces a geographic view, resource blocking can be disabled so images and scripts load normally, JavaScript rendering can be enabled explicitly, and custom headers can mimic a browser. These controls are not a guarantee against every block, but they make the request environment closer to a real shopper's session. Record which settings produced each result so you can compare runs.

Distinguish three common failures

A blocked request usually returns a non-200 status or a CAPTCHA page; check the status code first. An empty price column with a valid name often means the price selector no longer matches the live markup; inspect the page and update the selector. A price that differs from what you expect may be a localization or variation issue; confirm the country code and the specific ASIN variant. Separating these cases prevents you from changing proxies when the real problem is a stale selector.

Worked example with three ASINs

The supplied example uses three ASINs: B0CTH2QF23, B0CCDTPDTQ, and B099WTN2TR. The script requests each product page, extracts the name and price, and produces a table with one row per product. The CSV should contain the same rows in the same order as the ASIN list. If one ASIN returns an empty row, isolate that request and inspect the response before scaling up. This small batch is enough to confirm the selectors, the API key, and the output path.

Checklist before scaling up

Confirm Python 3.6 or newer is active. Confirm the client and pandas are installed. Confirm the API key is loaded from a safe source. Confirm the container, title, and price selectors match a current product page. Confirm the country code matches the market you want. Confirm the status code is 200 for each request. Confirm the CSV contains one row per ASIN and that empty rows are investigated. Only then add more ASINs or additional fields.

Frequently asked questions

Is it legal to scrape Amazon prices?

Yes, scraping available prices is legal. Still, review Amazon's Terms of Service and consult legal counsel to confirm compliance with the laws and policies that apply to you.

How often can I scrape prices from Amazon?

Amazon does not require a set interval between scrapes. Rather than sending requests in rapid succession, introduce pauses, allow retries, and rotate proxies so your traffic stays below detection thresholds. Scheduling scrapes at sensible intervals also reduces the likelihood of blocks.

Does Amazon block scraping bots?

Yes. Amazon employs CAPTCHAs, IP rate limits, and region checks. A scraping API can bypass these obstacles with automatic proxy rotation, server-side JavaScript rendering, smart retries, and configurable headers.

Can the workflow handle product variations like size or color?

Yes. Thanks to automatic JavaScript rendering, you can target variation-specific selectors such as selected swatch blocks, or loop through variation URLs or ASINs for precise pricing.

What should I do when the price column is empty?

Check the status code first. If the request succeeded but the price is missing, inspect the live product page and update the price selector. Amazon changes markup, so selector maintenance is expected.