Amazon Product Advertising API: Get Average Customer Rating

佐手、 提交于 2019-12-02 19:26:53
masi

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.

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/

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

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

This is not possible from PAPI. You either need to scrape it by yourself, or you can use other free/cheaper third-party alternatives for that.

We use the amazon-price API from RapidAPI for this, it supports price/rating/review count fetching for up to 1000 products in a single request.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!