Quote:
Originally Posted by kovidgoyal
If you can outline the procedure to get the ratings, I'm happy to code it
|
You bet. Amazon is great about this stuff. Lets say we want the review score for a book with ISBN 0596007973. First we'll need an Amazon
API developers ECS ID to make API queries. Then you just construct a URL such as:
http://ecs.amazonaws.com/onca/xml?Se...eGroup=Reviews
1CE7SK4ZPTNDQZCWBP82 is your ID key and 0596007973 is the ISBN. The rest of the URL is boilerplate.
It returns some XML. If we drill down to ItemLookupResponse->Items->Item->CustomerReviews->AverageRating we see the book got a score of 4.5.
Here's an example script that gets the rating for the above book:
Code:
import urllib2
from xml.dom import minidom
ACCESS_KEY_ID = "1CE7SK4ZPTNDQZCWBP82"
books_isbn = "0596007973"
ecsURL = "http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId="+ACCESS_KEY_ID+"&Operation=ItemLookup&ItemId="+books_isbn+"&ResponseGroup=Reviews"
ecsNameSpace = "http://webservices.amazon.com/AWSECommerceService/2005-10-05"
respXML = minidom.parse(urllib2.urlopen(ecsURL))
for items in respXML.getElementsByTagNameNS(ecsNameSpace, "Items"):
print items.getElementsByTagName("Item")[0].getElementsByTagName("AverageRating")[0].toxml()
Cheers,
Crazy