Can I keep track of my Amazon book rank with a script?
Dave, do you happen to have a script that will pull Amazon.com hourly sales rank data for 1 - N ASINs and save into either a CSV file or a database?
This isn't too hard to create, because Amazon has nicely formed URLs which make identifying a specific page easy, and has well-formed HTML that makes it easy to pull out the specific information.
Let's have a look...
My book Wicked Cool Shell Scripts has an ASIN (Amazon Stock Identification Number) of 1593270127.
Based on that, we can create a URL that has the ASIN embedded within to obtain the page that has information on that particular book:
http://www.amazon.com/exec/obidos/ tg/detail/-/asin/ref=nosimClick on this link and you'll see, if you add the properly formatted ASIN it takes you to the information page.
That's half the work, right? Now the other half is to figure out how to extract the Amazon Ranking value, and that's surprisingly easy to do:
lynx -dump "$target" | grep -i "Amazon.com Sales Rank"Where "target" is the URL shown earlier, with the appropriate ASIN. I run this snippet and here's what I see:
* Amazon.com Sales Rank in Books: #51,988That's what we want, so all we have to do is cut everything out but the numeric value, and that's easily done by noting that there's a "#" prefacing the value and using cut to split the line at that point.
Here's the full sequence to extract one ranking for one ASIN:
#!/bin/sh asin=1593270127 target="http://www.amazon.com/exec/obidos/tg/detail/-/$asin/ref=nosim" lynx -dump "$target" | grep -i "Amazon.com Sales Rank" | \ cut -d# -f2Run this, and you'll get the current sales rank.
To turn this into a script that loops through a file of ASINs should be straightforward, and to then save the output into a database or, say, comma separated values (CSV) file should be similarly easy.
I hope that gets you on the right track!
Related Shell Script Programming articles:
✔ Secretly capture screenshots on my Mac?
When I used to work on a Linux system, there was a utility we had that would let me take screen captures every...✔ Parsing "id" strings in a Shell Script?
Hello Dave. I need a Bash shell script that creates a directories with the group names automatically when user logs in to the...✔ Copy and Paste from the Mac OS X Command Line?
I am constantly running commands in Terminal.app on my MacBook and then copying and pasting the results into email messages or documents. Yes,...✔ Script to test line lengths for Twitter compatibility?
I've been tasked with writing a series of tweets for a Black Friday marketing campaign and am finding it a bit tricky because...✔ Shell script to convert lowercase to title case?
As part of a project I'm working on, I find myself deep in a Linux shell script, needing to have a subroutine that...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
I do have a comment, now that you mention it!
Check This Out Too...
Look for Answers
All Our Categories
Apple iPad Help
Articles and Reviews
Auctions and Online Shopping
Blogs and Blogging
Building Web Site Traffic
Business and Management
Computer and Internet Basics
d) None of the Above
Google Gmail Help
Google Plus Help
Industry News and Trade Shows
iPhone and Cell Phone Help
iPod, Sony PSP and MP3 Player Help
Kindle Fire Help
Mac OS X Help
Pay Per Click (PPC) Advertising
Search Engine Optimization (SEO)
Shell Script Programming
Tech Support Video Help
The Writing Business
Twitter, LinkedIn and Social Network Help
Unix and Linux Help
Video Game Tips and Help
Windows PC Help
Find Me on Google+
ADT on G+