Home Command line utilities Search Amazon Products From Command line

Search Amazon Products From Command line

By sk
Published: Last Updated on 995 views

The festival season has started! Amazon and other popular online retail firms are readying their battle rooms with discounts, exclusive products and other attractions for shoppers. If you're planning to shop on Amazon, I think I've got good news for you. Now you can search Amazon products from command line. Yes, you read right! Say hello to amzSear, an unofficial Amazon product CLI script & API. Using amzSear, you can easily search Amazon products from command line and view the basic product information such as all prices from different sellers, URL, ratings of any product, right from your Terminal window, without using the Amazon API. It is freely available in GitHub and released under MIT license.

Install amzSear in Linux

The amzSear requires Python 3 or higher version to work. Make sure you have installed pip on your system. If pip isn't installed already, install it as described in the following link.

Once pip installed, install amzSear using pip with command:

$ pip install amzsear

For those wanting to upgrade to version 2, use the command:

$ pip install amzsear --upgrade

Finally, install Pandas (Python Data Analysis Library). Installing Pandas is not required because it is not a required dependency for amzSear, however a few methods do use it (see AmzSear.md, AmzBase.md) if one wants to integrate with Pandas. If this is the case, pandas should be installed separately using the following command:

$ pip install pandas

Search Amazon Products From Command line

The typical command to use amzSear is:

amzsear query_string [-p num [-i num]] [-q] [-v] [-d]

Let me search a product, for example "Wings of Fire: An Autobiography of APJ Abdul Kalam" book, from Amazon:

$ amzsear 'Wings of Fire: An Autobiography of APJ Abdul Kalam'

Now, you will see the results based on your search string from amazon product directory in your Terminal.

Search Amazon Products From Command line Using amzsear

It will also display the results in your default web browser too.

Cool, isn't it?

You don't have to give the exact search term, just use the relevant search terms like "Abdul Kalam Books" and view the results both in Terminal and browser.

The amzSear script only displays the result from first page. We can also specify a particular page number to search as shown like below.

$ amzsear 'Abdul Kalam Books' -p 2

This command will display the results from the 2nd page of Amazon product directory.

Like I said, amzSear will display the result both in Terminal and web browser. If you don't want to display the result in Terminal but only in web browser, use -q flag like below.

$ amzsear 'Abdul Kalam Books' -p 2 -q

This command will display the 2nd page of the result only in web browser. You will not see any output in Terminal.

Likewise, if you want to view the result only in Terminal not in the web browser, use -d flag.

$ amzsear 'Abdul Kalam Books' -p 2 -d
 Name Price Rating
16 Indomitable Spirit 
17 Ignited Minds by A.P.J. Abdul Kalam (2014-11-01) 
18 Advantage India: From Challenge to Opportunity $12.99 
19 You are Born to Blossom *****
20 Target 3 Billion: Innovative Solutions Towards Sustaina $17.00 
21 Wings of Fire *****
22 Abdul Kalam 
23 'Your Kalam Set of 2 Books'. 
24 Guiding Souls (dialogues on the purpose of life) 
25 Forge Your Future $15.00 *****
26 Quran in Farsi Language (Tafseer Ahsan-ul-kalam) Arabic *****
27 Disappearing Daughters: The Tragedy of Female Foeticide $23.00 ****
28 (MY JOURNEY) (Tamil Edition) 
29 Learning How To Fly: Life Lessons For The Youth 
30 Intikhab-e-Kalam: Asghar Gondvi 
31 Beyond 2020: A Vision for Tomorrow's India *****

This command displays the 2nd page of the result only in your Terminal. It won't display the result in your web browser.

To display all information such as the product name, url, all prices, and rating string etc, use -v flag.

$ amzsear 'Abdul Kalam Books' -p 2 -d -v

This command displays the 2nd page of the result only in your Terminal, including all details such as URL, prices from different sellers, and ratings of the displayed products as shown in the below screenshot.

Remember it will not display the result in browser, because we included -d flag. If you want to display the result both in Terminal and browser, remove the -d flag.

A personal warning to those who frequently use this script for product hunting in Amazon. Amazon has flagged out many similar scripts as a scraping bot and banned the IP addresses that sends repetitive queries in the past. So, I suggest you to run it through a VPN or proxy or limit your search per day until the developer comes with an alternative workaround.

Happy shopping!

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More