Scraping ASIN codes from Amazon is easier than you think. Okay, you can manually grab the ASIN codes from product pages URLs, but you can also get them from the search results too.
This can be done with an Amazon page, and a little XPath query. Fortunately, you can run XPath queries in Chrome, so you don’t have to install anything out of the ordinary.
Don’t worry if you’re not the most technically gifted, it’s easy to do, and I’ve included the code for you below!
Navigate to the Amazon page that you want to scrape
Open up Amazon, and a search for a keyword. Once the page has loaded up, you’ll see a bunch of items, and we’ll get to the scraping.
Make sure that the page that you’ve opened is a search results page. There’s no point mass scraping a single product page. Just copy the ASIN from the URL instead.
Locate the data-asin attributes
Inspect element (right-click, click Inspect Element) on ones of the product listings, and you’ll see that there’s a “data-asin” attribute, with the product’s ASIN.
It might not be immediately obvious, but it’ll be there. Just goto the parent container of the HTML element.
Run this XPath query in your browser console
Next to the “elements” tab, in the inspect element panel, there’s a tab called “Console”.
You can paste in the above code, and it’ll scrape all the ASIN codes on the page.
Then, after you paste in the code, you’ll see a preview of the returned values. These should be the ASIN codes that you’re searching for.
Press enter and you’ll have a nicely formatted list of ASIN codes, freshly scraped for your usage!
If you have any questions, fire away in the comments below.
Until next time,