How To Scrape Amazon Reviews Using Python (2025)
Amazon is the go-to marketplace for millions of shoppers. And what’s the first thing people check before buying? The reviews.
Whether you're a brand, a marketer, or just someone doing research, getting access to a large number of Amazon reviews can be incredibly valuable.
But there’s a problem: Amazon doesn’t make it easy. As of November 5th, 2024, you now have to be logged in to see more than a handful of reviews.
This means scraping Amazon reviews the old-fashioned way has become a nightmare. Bots get blocked, CAPTCHAs pop up everywhere, and unless you like dealing with login sessions and headless browsers, you’re in for a rough time.
In this turorial, we will teach you the two methods for web scraping Amazon reviews.
Two Methods to Scrape Amazon Reviews
There are two primary ways to extract Amazon reviews:
- Using Python: A DIY method where you write a scraper using BeautifulSoup and requests.
- Using Unwrangle API: A hassle-free approach that bypasses login restrictions, CAPTCHAs, and geo-restrictions.
In this guide, we’ll walk you through both methods and explain what each approach can scrape.
What We Will Scrape In This Tutorial
With Python Method:
- Product Title
- Reviewer Names
- Review Titles
- Review Texts
- Review Ratings
- Review Dates
- Review Images (if available)
With Unwrangle API Method:
- Everything Python can scrape, plus:
- More reviews than Amazon allows per page
- Filter reviews by keywords (e.g., "battery life")
- Filter by positive or critical reviews
- Retrieve reviews from more countries
- Fetch reviews for all variants or a specific one
- Get media reviews only (images/videos)
Let's first understand how Amazon prevents scraping.
Understanding Amazon's Anti-Scraping Measures
Amazon implements multiple layers of security to prevent automated data extraction, making it challenging for scrapers. Here are some of the major obstacles:
Method 1: Step-by-Step Guide to Extracting Amazon Reviews Using Python
Step 1: Install Required Libraries
Ensure you have requests
, beautifulsoup4
and csv
installed:
1pip install requests beautifulsoup4 csv
Step 2: Import Libraries
1import requests2from bs4 import BeautifulSoup3import time4import random5import csv
Step 3: Define Headers to Avoid Blocks
Amazon aggressively blocks bots, so you should use headers to mimic a real browser.
1headers = {2 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",3 "Accept-Language": "en-US,en;q=0.9",4}
Step 4: Fetch the Amazon Product Page
Replace URL_HERE
with the actual Amazon product page URL.
1url = "URL_HERE"2response = requests.get(url, headers=headers)3if response.status_code != 200:4 print("Failed to retrieve the page. Status code:", response.status_code)5 exit()6soup = BeautifulSoup(response.content, "html.parser")
Step 5: Extract Data from Reviews
Finding the Selectors for Specific Elements
To extract these attributes, you'll need to locate their unique CSS selectors. Use your browser's Inspect tool (F12) to examine the page's structure and identify the relevant selectors.
For example:
- Reviewer Name is in the
<span>
tag with the classa-profile-name
- Review Title is found in an
<a>
tag withdata-hook="review-title"
- Review Text is stored in a
<span>
tag withdata-hook="review-body"
- Review Rating is found inside an
<i>
tag withdata-hook="review-star-rating"
- Review Date appears in a
<span>
tag withdata-hook="review-date"
- Review Images can be found in the
src
attribute of an<img>
tag withdata-hook="review-image-tile"
Extract Reviewer Names
1reviewer_names = [name.text.strip() for name in soup.select(".a-profile-name")]
Extract Review Titles
1review_titles = [2 title.find_all("span")[-1].text.strip() # Extract last span inside <a data-hook="review-title">3 for title in soup.find_all("a", {"data-hook": "review-title"})4 ]
Extract Review Texts
1review_texts = [text.text.strip() for text in soup.select('[data-hook="review-body"]')]
Extract Review Ratings
1review_ratings = [rating.text.strip() for rating in soup.find_all("i", {"data-hook": "review-star-rating"})]
Extract Review Dates
1review_dates = [date.text.strip() for date in soup.select('[data-hook="review-date"]')]
Extract Review Images (if available)
1review_images = []2for img in soup.find_all("img", {"data-hook": "review-image-tile"}):3 image_url = img.get("data-src", img.get("src", "N/A")) # Uses `data-src` if available, otherwise `src`4 review_images.append(image_url)
Step 6: Save Reviews to CSV
1with open("amazon_reviews.csv", "w", newline="", encoding="utf-8") as file:2 writer = csv.writer(file)3 writer.writerow(["Reviewer Name", "Review Title", "Review Text", "Review Rating", "Review Date", "Review Images"])45 for i in range(len(reviewer_names)):6 writer.writerow([7 reviewer_names[i] if i < len(reviewer_names) else "N/A",8 review_titles[i] if i < len(review_titles) else "N/A",9 review_texts[i] if i < len(review_texts) else "N/A",10 review_ratings[i] if i < len(review_ratings) else "N/A",11 review_dates[i] if i < len(review_dates) else "N/A",12 review_images[i] if i < len(review_images) else "N/A"13 ])1415print("Reviews successfully saved to amazon_reviews.csv")
Preview:
You can also check our tutorial on how to scrape Amazon product details with python.
Method 2: Scraping Amazon Reviews Using Unwrangle API
Unwrangle offers a far superior alternative to manual scraping:
-
Retrieve reviews from more countries
-
Filter reviews by keyword (e.g., "battery life")
-
Get more reviews than allowed per page
-
Filter by positive or critical reviews
-
Fetch reviews for all or specific variants
-
Retrieve media reviews only (images/videos)
For more Info Check Our Documentation Page: Amazon Product Reviews API
How to Use Unwrangle API to Scrape Amazon Reviews
Step 1: Prerequisites
Before making API requests, ensure you have the following:
- Requests library
Run the following command from your terminal(if you don't have the
requests
library installed already):
1pip install requests
- Unwrangle API Key: Sign up on Unwrangle to get one
- Amazon Cookie: Extract your session cookie after logging in to Amazon
How to Get or Extract Amazon Cookies:
To scrape Amazon reviews, you need to provide your Amazon session cookie (cookie
parameter). Here’s how you can extract it from your browser:
- Go to Amazon and log into your account.
- Right-click anywhere and select Inspect.
- Navigate to the Application tab.
- Under Storage, click Cookies and select
amazon.com
. - Look for a cookie named
session-id
orsession-token
. - Copy its value and use it in your API request.
Step 2: Making a Basic API Request
Use the following Python script to fetch Amazon reviews using Unwrangle:
1import requests23API_URL = "https://data.unwrangle.com/api/getter/"45params = {6 "url": "https://www.amazon.com/essence-Princess-Effect-Mascara-Cruelty/dp/B00T0C9XRK",7 "page": 1,8 "platform":"amazon_reviews",9 "filter_by_star": "positive", # Filter by positive reviews10 "sort_by": "recent", # Or "helpful"11 "api_key": "YOUR_API_KEY",12 "media_type": "media_reviews_only", # Fetch only image/video reviews13 "cookie": "YOUR_AMAZON_COOKIE"14}1516response = requests.get(API_URL, params=params)17data = response.json()18print(data["reviews"])
Step 3: Response Format
Each request returns up to 10 results. The response will include the following attributes:
Attributes Returned | Data Type | Information Represented |
---|---|---|
id |
string |
Retailer ID of the review |
date |
string |
Date when review was published |
author_name |
string |
Reviewer's name |
author_url |
string |
Reviewer's retailer profile link |
rating |
int |
Rating by reviewer |
review_title |
string |
Review title |
review_url |
string |
Link to review |
review_text |
string |
Review's text content |
review_imgs |
list |
Links to reviewer's images, if any |
review_videos |
list |
Links to reviewer's videos, if any |
meta_data |
dict |
Dict containing meta data. For example, verified purchase status and variant info |
meta_data.verified_purchase |
boolean |
Whether the review is from a verified purchase |
meta_data.variant_info |
list |
List of variant details for the reviewed product |
meta_data.helpful_vote_count |
int |
Number of helpful votes for the review |
location |
string |
Country-level location of reviewer |
rating_distribution |
dict |
Distribution of ratings for the product |
Step 4: Handling the API Response
Once you receive the JSON response, you can extract and analyze the data:
1if response.status_code == 200:2 reviews = data.get("reviews", [])3 for review in reviews:4 print(f"Rating: {review['rating']}, Review: {review['review_text']}")5else:6 print(f"Error: {data.get('message', 'Unknown error')}")
Preview:
More Ways to Scrape Amazon Data
If you are looking for other Amazon data we have also APIs for:
-
Amazon Search Results API: Scrape Amazon search results, including product listings, prices, and availability.
-
Amazon Product Data API: Extract Amazon product data, ratings, and purchase insights.
-
Amazon Category Data API: Retrieve Amazon category listing, including top products, rankings, and pricing trends.
With these, you can Instantly retrieve product details like prices, images, and descriptions. Easily fetch customer reviews, including ratings and review text. Get structured JSON responses that are easy to integrate into your code.