Create Amazon Scraper in Python using Scraper API

In this post of ScrapingTheFamous, I am going o write a scraper that will scrape data from Amazon. I do not need to tell you what is Amazon. You are here because you already know about it 🙂

So, we are going to write two different scripts: one would be that would be fetching URLs of individual listings and save in a text file. Later another script, that will have a function taking an individual listing URL, scrape data, and save in JSON format.

I will be using Scraper API service for parsing purposes which makes me free from all worries blocking and rendering dynamic sites since it takes care of everything.

The first script is to fetching listings of a category. So let’s do it!

import requests
from bs4 import BeautifulSoup

So here is the script. I picked the electronics category, you may choose anyone you want. I arranged relevant headers. You can either pick manually via Chrome Inspector or use to do this for you by copying the cURL request.

I am using the ScraperAPI API endpoint by setting both the payload and api_key. I am using h2 > .a-link-normal selector because there are many .a-link-normal links which are not required so I am using h2 > to make sure to pick the required links.

Once we have links we will be saving in a text file.

Now the next part of the post is about parsing the info:

import requests
from bs4 import BeautifulSoup

Pretty straightforward. I fetched title, scraped Amazon ASIN, and other stuff. You can scrape many other things like Amazon reviews as well. The data is stored in JSON format.


In this post, you learned how you can scrape Amazon data easily by using Scraper API in Python. You can enhance this script as per your need like writing a price monitoring script or as an ASIN scraper.

Writing scrapers is an interesting journey but you can hit the wall if the site blocks your IP. As an individual, you can’t afford expensive proxies either. Scraper API provides you an affordable and easy to use API that will let you scrape websites without any hassle. You do not need to worry about getting blocked because Scraper API by default uses proxies to access websites. On top of it, you do not need to worry about Selenium either since Scraper API provides the facility of a headless browser too. I also have written a post about how to use it.

Click here to signup with my referral link or enter promo code adnan10, you will get a 10% discount on it. In case you do not get the discount then just let me know via email on my site and I’d sure help you out.

Originally published at on November 16, 2020.

Pakistani | Husband | Father | Software Consultant | Developer | blogger. I occasionally try to make stuff with code.