Drew
Drew

Reputation: 1937

Amazon Product Advertising API: Get Average Customer Rating

When using Amazon's web service to get any product's information, is there a direct way to get the Average Customer Rating (1-5 stars)? Here are the parameters I'm using:

Service=AWSECommerceService
Version=2011-08-01
Operation=ItemSearch
SearchIndex=Books
Title=A Game of Thrones
ResponseGroup=Large

I would expect it to have a customer rating of 4.5 and total reviews of 2177. But instead I get the following in the response.

<CustomerReviews><IFrameURL>http://www.amazon.com/reviews/iframe?...</IFrameURL></CustomerReviews>

Is there a way to get the overall customer rating, besides for reading the <IFrameURL/> value, making another HTTP request for that page of reviews, and then screen scraping the HTML? That approach is fragile since Amazon could easily change the reviews page structure which would bust my application.

Upvotes: 14

Views: 14103

Answers (5)

Igor Krupitsky
Igor Krupitsky

Reputation: 885

Here is a VBS script that would scrape the rating. Paste the code below to a text file, rename it to Test.vbs and double click to run on Windows.

sAsin = InputBox("What is your ASIN?", "Amazon Standard Identification Number (ASIN)", "B000P0ZSHK")
if sAsin <> "" Then
  sHtml = SendData("http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=" & sAsin)
  sRating = ExtractHtml(sHtml, "<span class=""a-size-base a-color-secondary"">(.*?)<\/span>")
  sReviews = ExtractHtml(sHtml, "<a class=""a-size-small a-link-emphasis"".*?>.*?See all(.*?)<\/a>")
  MsgBox sRating & vbCrLf & sReviews
End If

Function ExtractHtml(sHtml,sPattern)
  Set oRegExp = New RegExp
  oRegExp.Pattern    = sPattern
  oRegExp.IgnoreCase = True
  Set oMatch = oRegExp.Execute(sHtml)
  If oMatch.Count = 1 Then
      ExtractHtml = Trim(oMatch.Item(0).SubMatches(0))
  End If
End Function

Function SendData(sUrl)
  Dim oHttp 'As XMLHTTP30
  Set oHttp = CreateObject("Msxml2.XMLHTTP")
  oHttp.open "GET", sUrl, False
  oHttp.send
  SendData = Replace(oHttp.responseText,vbLf,"")
End Function

Upvotes: 2

JeffBezos
JeffBezos

Reputation: 241

You can scrape from here. Just replace the asin with what you need.

http://www.amazon.com/gp/customer-reviews/widgets/average-customer-review/popover/ref=dpx_acr_pop_?contextId=dpx&asin=B000P0ZSHK

Upvotes: 24

Struggler
Struggler

Reputation: 682

Amazon has completely removed support for accessing rating/review information from their API. The docs mention a Response Element in the form of customer rating, but that doesn't work either.

Google shopping using Viewpoints for some reviews and other sources

Upvotes: 0

Steve
Steve

Reputation: 21

You can grab the iframe review url and then use css to position it so only the star rating shows. It's not ideal since you're not getting raw data, but it's an easy way to add the rating to your page.

Sample of this in action - http://spamtech.co.uk/positioning-content-inside-an-iframe/

Upvotes: 2

omni
omni

Reputation: 4495

As far as i know, Amazon changed it's API so its not possible anymore to get the reviewrank information. If you check this Link the note sais:

As of November 8, 2010, only the iframe URL is returned in the request content.

However, testing with the params you used to get the Iframe it seems that now even the Iframe dosn't work anymore. Thus, even in the latest API Reference in the chapter "Motivating Customers to Buy" the part "reviews" is compleatly missing.

However: Since i'm also very interested if its still possible somehow to get the reviewrank information - maybe even not using amazon API but a competitors API to get review rank informations - i'll set up a bounty if anybody can provide something helpful on that. Bounty will be set in this topic in two days.

Upvotes: 4

Related Questions