Blog

How to Scrape Amazon with Python: Scraper vs API

A Python Amazon scraper with requests and BeautifulSoup, why it breaks, and product, search and bulk examples with the Easyparser API.


Written and reviewed by
Data Extraction Updated: Read time: 11 minutes
Frustrated developer surrounded by web scraping obstacles including CAPTCHA challenges, IP blocked errors, 404 responses, access denied warnings, and HTML code fragments, illustrating the common pain points of manual Amazon scraping.

If you want to know how to scrape Amazon with Python, there are two realistic routes. The first is a do-it-yourself scraper: download the product page with requests, parse the HTML with BeautifulSoup and pick out the title and price. The second is to call an Amazon data API from Python and receive the same information as JSON. This guide walks through both, explains where the first route fails in practice, and gives working Python code for product details, keyword search and bulk jobs with the Easyparser Amazon scraping API.

Route 1: A Basic Amazon Scraper in Python

The classic Python toolkit for web scraping is requests for HTTP and BeautifulSoup for parsing. Install both first:

pip install requests beautifulsoup4

A minimal Amazon web scraper in Python looks like this. It requests a product page, checks whether the response is a real product page, and reads two elements by their HTML ids and classes:

import requests

from bs4 import BeautifulSoup

url = "https://www.amazon.com/dp/B0CJB6V2L5"

headers = {"User-Agent": "Mozilla/5.0", "Accept-Language": "en-US,en;q=0.9"}

response = requests.get(url, headers=headers, timeout=30)

print("HTTP status:", response.status_code)

if response.status_code != 200 or "captcha" in response.text.lower():

print("Blocked or challenged: no product data in this response")

else:

soup = BeautifulSoup(response.text, "html.parser")

title = soup.select_one("#productTitle")

price = soup.select_one("span.a-offscreen")

print("Title:", title.get_text(strip=True) if title else None)

print("Price:", price.get_text(strip=True) if price else None)

Run it a few times and you will usually see one of three outcomes: the data you wanted, an error status such as 503, or a page asking you to confirm you are not a robot. The selectors #productTitle and span.a-offscreen are common on product pages today, but they are not a contract. Amazon can change them at any time, and a price element can exist several times on one page (list price, deal price, other offers), so the first match is not always the price a shopper pays.

Flowchart of a do-it-yourself Python Amazon scraper: HTTP request, headers, proxy configuration, HTML parsing with BeautifulSoup and data extraction, with possible failure points after the request and the parsing step.

Why Do-It-Yourself Amazon Scrapers Break

The basic script is a useful exercise, but it does not survive contact with production volumes. Four problems show up in almost every in-house Amazon scraper:

  • Blocks and rate limits. Amazon watches request patterns. Repeated requests from one IP address get throttled, answered with error pages or blocked.
  • CAPTCHAs. Suspicious traffic receives a challenge page instead of the product. Your parser then finds nothing, and without the check above the script fails with an AttributeError or silently stores empty values.
  • Dynamic and varying pages. Layouts differ by category, seller and promotion, and some content such as offers, delivery messages or variations loads after the first HTML response. Covering that means a headless browser such as Selenium or Playwright, which is slower and heavier to run.
  • Location-dependent results. Price, stock and delivery dates change with the delivery address. A script running on a server in one country sees a different page than a shopper in another, so the numbers you collect may not match your market.

Tutorials often answer these problems with rotating user agents, proxy pools and CAPTCHA solvers. We do not publish code for getting around Amazon's protections. Beyond the technical arms race, Amazon's Conditions of Use exclude "data mining, robots, or similar data gathering and extraction tools" from the license they grant, so the more effort a script spends disguising itself, the clearer it is that it operates outside that license. Read the section on rules below before you build anything at scale.

What about Scrapy?

Scrapy is an excellent Python framework for crawling: it schedules requests, runs them concurrently, retries failures and exports items. It does not change how Amazon responds to automated traffic, so a Scrapy Amazon spider hits the same blocks and CAPTCHAs as a requests script, only faster. If your team already uses Scrapy, you can keep it for scheduling and point it at an API instead of at Amazon pages. An example follows later in this guide.

Route 2: Scrape Amazon with Python Through an API

A scraping API moves page retrieval, parsing, IP block and CAPTCHA handling to the provider. Your Python code sends parameters and receives structured JSON with stable field names. With Easyparser, every real-time request goes to one endpoint, GET https://realtime.easyparser.com/v1/request, with these query parameters:

ParameterExamplePurpose
api_keyYOUR_API_KEYYour key from the Easyparser web app (Account > Plan)
platformAMZTarget platform: Amazon
operationDETAIL, SEARCH, OFFER ...Which kind of Amazon data you want
domain.com, .co.uk, .deAmazon marketplace, written with a leading dot
asin or keywordB0CJB6V2L5 / vacuum bottleInput for DETAIL / SEARCH
zip_code (optional)10001Delivery location, so prices and stock match a real address

Easyparser covers 22 Amazon marketplaces and accepts a delivery location with the request, which solves the location problem from the previous section without running servers in each country.

Get product details by ASIN (DETAIL)

This is the API version of the BeautifulSoup script above. It requests the same ASIN, checks request_info.success and reads fields from result.detail:

import requests

API_KEY = "YOUR_API_KEY"

params = {

"api_key": API_KEY,

"platform": "AMZ",

"operation": "DETAIL",

"domain": ".com",

"asin": "B0CJB6V2L5",

}

response = requests.get("https://realtime.easyparser.com/v1/request", params=params, timeout=120)

data = response.json()

if data.get("request_info", {}).get("success"):

detail = data["result"]["detail"]

buybox = detail.get("buybox_winner", {})

print("Title:", detail.get("title"))

print("Rating:", detail.get("rating"), "from", detail.get("ratings_total"), "ratings")

print("Price:", buybox.get("price", {}).get("raw"))

print("Stock:", buybox.get("availability", {}).get("raw"))

else:

print("Request failed:", data.get("request_info", {}).get("error_details"))

For this ASIN, the published example response contains the following values (title shortened):

Title: Simple Modern 36oz Insulated Hot Beverage Bottle with 2 Mugs ...

Rating: 4.6 from 779 ratings

Price: $29.99

Stock: In Stock

The same result.detail object also holds brand, images, feature bullets, variations, categories, Best Sellers Rank and more. The full field list is on the Amazon product detail API page and in the documentation. Note that values come from the live page: always check for missing fields instead of assuming every product has every value.

Search Amazon by keyword (SEARCH)

Product research and rank tracking start from search results. The SEARCH operation takes a keyword and returns the result list in result.search_results, including the position, ASIN, price, rating and whether a listing is sponsored. One results page costs one credit; you can request a window of up to five pages with min_page and max_page.

import requests

params = {

"api_key": "YOUR_API_KEY",

"platform": "AMZ",

"operation": "SEARCH",

"domain": ".com",

"keyword": "vacuum bottle",

"page": 1,

}

data = requests.get("https://realtime.easyparser.com/v1/request", params=params, timeout=120).json()

for item in data.get("result", {}).get("search_results", []):

label = "sponsored" if item.get("is_sponsored") else "organic"

price = (item.get("price") or {}).get("raw")

print(item.get("asin"), label, price, item.get("rating"), item.get("title", "")[:50])

Read more about separating sponsored and organic positions in our guide to Amazon search results scraping, or see the Amazon search API page for all parameters such as sort_by and exclude_sponsored.

Save results to CSV

Most first projects end in a spreadsheet. The standard library is enough to turn a list of ASINs into a CSV file:

import csv

import requests

ASINS = ["B0CJB6V2L5", "B000FZX93K"]

rows = []

for asin in ASINS:

params = {"api_key": "YOUR_API_KEY", "platform": "AMZ", "operation": "DETAIL", "domain": ".com", "asin": asin}

data = requests.get("https://realtime.easyparser.com/v1/request", params=params, timeout=120).json()

if not data.get("request_info", {}).get("success"):

continue

d = data["result"]["detail"]

price = d.get("buybox_winner", {}).get("price", {}).get("value")

rows.append({"asin": asin, "title": d.get("title"), "price": price, "rating": d.get("rating")})

with open("amazon_products.csv", "w", newline="", encoding="utf-8") as f:

writer = csv.DictWriter(f, fieldnames=["asin", "title", "price", "rating"])

writer.writeheader()

writer.writerows(rows)

For long-running jobs, add retries with backoff for temporary errors and log permanent ones separately. Our Python retry and error handling guide shows a reusable pattern.

Using the API from Scrapy

If you prefer Scrapy for scheduling and pipelines, request the API URL instead of the Amazon page. Scrapy then handles concurrency and item export, and the API handles Amazon:

import scrapy

from urllib.parse import urlencode

class AmazonApiSpider(scrapy.Spider):

name = "amazon_api"

asins = ["B0CJB6V2L5", "B000FZX93K"]

def start_requests(self):

for asin in self.asins:

query = {"api_key": "YOUR_API_KEY", "platform": "AMZ", "operation": "DETAIL", "domain": ".com", "asin": asin}

yield scrapy.Request("https://realtime.easyparser.com/v1/request?" + urlencode(query))

def parse(self, response):

detail = response.json().get("result", {}).get("detail", {})

yield {"asin": detail.get("asin"), "title": detail.get("title"), "rating": detail.get("rating")}

Illustration of a verified API connection sending data through a fast pipeline with checkpoints into a structured dashboard displaying JSON objects and data tables, representing a reliable API data integration workflow.

Scaling Up: Bulk Requests in Python

Looping over real-time calls is fine for dozens of ASINs. For thousands, send one asynchronous bulk request. The Bulk API accepts up to 5,000 inputs per request, sends a notification to your callback_url when results are ready, and you fetch each result from the Data Service. Parsed results are kept for up to 24 hours, so store them when the webhook arrives.

import requests

API_KEY = "YOUR_API_KEY"

job = [{

"platform": "AMZ",

"operation": "DETAIL",

"domain": ".com",

"callback_url": "https://your-app.example/webhook",

"payload": {"asins": ["B0CJB6V2L5", "B000FZX93K", "B01DZQT3IU"]},

}]

submitted = requests.post("https://bulk.easyparser.com/v1/bulk", headers={"api-key": API_KEY}, json=job, timeout=300).json()

query_ids = [r["id"] for group in submitted["data"]["accepted"] for r in group["results"]]

print("Accepted queries:", len(query_ids))

# Later, after the webhook says a query is finished:

for qid in query_ids:

url = f"https://data.easyparser.com/v1/queries/{qid}/results?format=json"

record = requests.get(url, headers={"api-key": API_KEY}, timeout=60).json()

print(qid, record["data"]["status"])

A bulk response can be partly accepted, so also inspect the invalid, failed and insufficient_credit lists. The Amazon Bulk API guide covers webhooks and scheduling in detail.

DIY Scraper vs API: A Quick Comparison

Arearequests + BeautifulSoupEasyparser API from Python
SetupInstall two libraries, write selectorsInstall requests, add an API key
Blocks and CAPTCHAsYour problem; responses fail or come back emptyHandled by the provider; you get data or a clear error
Page changesSelectors break and need maintenanceStable JSON field names
Delivery locationWhatever your server location seeszip_code or a saved address per request
VolumeLimited by blocks and infrastructureReal-time calls plus bulk jobs of up to 5,000 inputs
CostNo fees, but proxies, servers and engineering timeCredits per successful result; 100 free credits to start

What About an Official Amazon Product API for Python?

Many people searching for a "Python Amazon product API" are looking for an official option. Amazon has two, built for specific audiences. The Selling Partner API is for sellers and vendors working with their own business data, after developer registration and seller authorization. For affiliates, Amazon has deprecated the Product Advertising API 5.0 and replaced it with the Creators API, which requires an accepted Associates account with recent qualifying sales. If you are a seller or an affiliate, check those first. For public marketplace data on any ASIN, such as competitor prices, offers and search rankings, a scraping API is the usual route. Our comparison of Amazon SP-API vs scraping and the overview of Amazon product data extraction methods explain the trade-offs.

Is It Legal to Scrape Amazon with Python?

There is no single answer: it depends on your jurisdiction, the data and how you use it. Amazon's Conditions of Use restrict data mining and extraction tools, so treat data collection as a governance question, not only a coding task. Practical rules: collect only publicly visible product data, never personal data or anything behind a login, keep request rates reasonable, document why you need the data and get legal advice for commercial projects at scale. A scraping API improves reliability and control, but it does not replace that review.

Get Started

The fastest way to compare both routes is to run them side by side on your own ASINs. Create a free Easyparser account to get 100 credits with no credit card required, paste your API key into the DETAIL example and compare the JSON with what your BeautifulSoup script returns. For a broader introduction to how scraping APIs work, read our Amazon scraping API guide.

Sources

  1. Real-Time Integration Overview, Easyparser Documentation (accessed )
  2. Search: Request, Easyparser Documentation (accessed )
  3. Data Service Request, Easyparser Documentation (accessed )
  4. Conditions of Use, Amazon (accessed )
  5. PA-API 5 Deprecation Notice, Amazon Associates (accessed )

Start extracting Amazon data for free

Start Your Free Trial

100 free credits, no credit card required.

Frequently Asked Questions (FAQ)

You can download a product page with requests and parse it with BeautifulSoup, but Amazon often answers automated requests with blocks or CAPTCHA pages, and selectors change. For reliable results, call an Amazon data API such as Easyparser from Python and read structured JSON fields instead of HTML.

For parsing pages, requests with BeautifulSoup or lxml is the usual starting point, and Selenium or Playwright for JavaScript content. With an API, the requests library is enough, because the response is already structured JSON.

Scrapy handles scheduling, concurrency and export well, but it does not stop Amazon from blocking or challenging automated traffic. Many teams keep Scrapy for orchestration and request an Amazon data API instead of Amazon pages.

Amazon detects automated request patterns and answers with error pages or challenges. Check the status code and page content before parsing. Easyparser handles IP blocks and CAPTCHAs on its side and returns data or a clear error.

Amazon offers the Selling Partner API for sellers and vendors and the Creators API for qualifying Associates; the Product Advertising API 5.0 is deprecated. Both serve specific audiences. For public data on any ASIN, a scraping API is the common choice.

Use a bulk request. Easyparser accepts up to 5,000 inputs per bulk request, notifies your webhook when results are ready, and keeps parsed results for up to 24 hours on its Data Service.

It depends on jurisdiction, data and use. Amazon's Conditions of Use restrict data mining and extraction tools, so collect only public, non-personal data, rate-limit requests and get legal advice for commercial projects.

Create a free account to get 100 credits with no credit card required, copy your API key and run the DETAIL example from this guide.
Tags
how to scrape amazon with pythonscrape amazon pythonamazon scraper pythonamazon web scraper pythonpython amazon product apiscrapy amazonbeautifulsoup amazoneasyparser