Skip to content

About

Amazon scraper in Python: product prices, ratings, coupons and "bought in past month" to CSV, price drop alerts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Amazon scraper in Python: product prices, ratings and price drops

This repository calls a paid Apify Actor built by Flatrow Data Studio (the author). Links to apify.com carry the author's affiliate code: the author may earn a commission if you sign up to Apify through them, at no extra cost to you.

A small Amazon scraper in Python. scrape.py searches Amazon for one or more keywords and saves one row per product to CSV: ASIN, title, price, list price and discount, rating and number of ratings, "bought in past month", coupon, Amazon's Choice and Best Seller badges, sponsored flag, delivery and position in the results, on amazon.com, amazon.co.uk, amazon.de, amazon.fr, amazon.it, amazon.es, amazon.com.mx, amazon.co.jp or amazon.ca. monitor_prices.py turns the same search into an Amazon price tracker that returns only the price drops, price rises and new products since its previous run.

Both scripts run the Amazon Products Scraper & Price Tracker on Apify through the official apify-client package: the Actor runs in Apify's cloud and returns clean rows, so there is no browser, HTML parsing or proxy to maintain on your side. No login, no cookies, and no personal data: nothing about buyers, reviewers or third-party sellers is collected.

Use cases

  • Price drop alerts: a daily cron job that prints the products of a search whose price went down.
  • Competitor price monitoring for sellers and brands: prices, discounts, coupons and rank of each ASIN for your keywords.
  • Market and niche research: price distribution, ratings, monthly purchases and share of sponsored results, ready for pandas or Excel.
  • Compare marketplaces: the same keywords on amazon.com, amazon.co.uk and amazon.de.

Installation

You need Python 3.11 or later and a free Apify account (the free plan includes monthly credit).

git clone https://github.com/flatrow-data-studio/amazon-scraper-python.git
cd amazon-scraper-python
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
export APIFY_TOKEN="<your-apify-token>"   # Apify Console > Settings > API & Integrations

Run it

# 60 "wireless earbuds" on amazon.com
python scrape.py "wireless earbuds" --max-results 60

# Air fryers between 50 and 100 USD, best reviewed first, without sponsored products
python scrape.py "air fryer" --price-min 50 --price-max 100 --sort avg_review --no-sponsored

The script writes amazon_products.csv (change it with --output) and prints the five cheapest products. Other options: several keywords in one run ("usb c cable" "usb c charger"), --marketplace (US, UK, DE, FR, IT, ES, MX, JP, CA), --sort (relevance, price_low, price_high, avg_review) and --max-charge 0.50 to stop a run once it has cost 50 cents; python scrape.py --help lists them all.

Track prices every day

python monitor_prices.py "robot vacuum" --price-max 300 --store amazon-robot-vacuums

The first run records the price of every product as the reference (they all come back as new). From the second run on, only the new products and the products whose price changed are returned, with previousPrice, priceDelta and priceDeltaPercent; they are printed and appended to amazon_price_changes.csv. The reference lives in a key-value store of your Apify account (--store, amazon-price-monitor by default; use one name per schedule), so the script can run from cron on any machine:

0 7 * * * cd /path/to/amazon-scraper-python && .venv/bin/python monitor_prices.py "robot vacuum" --price-max 300 --store amazon-robot-vacuums >> tracker.log 2>&1

Keep the same keywords, marketplace, sort and filters from run to run: changing them starts a new reference.

Sample output

One real row from a "wireless earbuds" search on amazon.com, key columns only:

{
  "platformProductId": "B0HDB173YV",
  "title": "Wireless Earbuds, Bluetooth 6.0 Headphones HiFi Stereo 50H Playback LED Digital Display Ear Buds with ENC Noise Canceling Headset, IPX7 Waterproof Earphones for Gym/Running/Work(White)",
  "currency": "USD",
  "price": 19.97,
  "originalPrice": 249.99,
  "discountPercent": 92,
  "rating": 4.8,
  "reviewCount": 183,
  "isChoice": true,
  "searchRank": 1
}

Columns

scrape.py writes these columns:

Column Meaning
platformProductId ASIN
title Product title
currency Currency of the prices
price Current price
originalPrice List price, typical price or former price
discountPercent Discount against originalPrice
rating Average rating out of 5
reviewCount Number of ratings
isChoice Amazon's Choice badge
isBestSeller Best Seller badge
isSponsored Sponsored result
shippingFree Free delivery
deliveryEstimate Delivery wording as Amazon shows it
searchQuery The keywords that found the product
searchRank Position in the results
url Product link
boughtPastMonth "Bought in past month" figure, from the attributes column
coupon Coupon shown on the result, from the attributes column

The dataset of each run has more columns (image, stock warnings, colours, Amazon as the seller, marketplace...): add their names to COLUMNS in scrape.py, or keys of attributes to ATTRIBUTES. The full list is on the Actor page.

Pricing

The Actor is pay-per-event: from $1.50 per 1,000 products on Apify's Free plan, lower on paid plans, with compute and proxies included. Apify's free monthly credit of $5 covers about 3,333 products. You pay per product saved and nothing else; --max-results caps every keyword of a run, and in price-tracking mode only the new and changed products are saved and charged.

FAQ

Do I need to write a scraper or run a browser? No. The Actor runs in Apify's cloud and is kept up to date when Amazon changes its pages; your script receives JSON rows.

Can I paste an Amazon search URL with my filters? Yes: the Actor also takes startUrls, search URLs copied from your browser. Put them in run_input in place of searchQueries in build_input; the Actor page documents every input field.

Is there personal data in the output? No. Rows contain product facts, the average rating and the number of ratings; a seller is named only when it is Amazon itself, and nothing about buyers or reviewers is collected. Use the data for analysis, respect Amazon's terms and the law of your country, and do not republish listings.

Related

Other Python examples by Flatrow Data Studio, all with a CSV export and a price tracker:

License

MIT, see LICENSE. Amazon is a trademark of its owner; this project is not affiliated with Amazon.

About

Amazon scraper in Python: product prices, ratings, coupons and "bought in past month" to CSV, price drop alerts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages