O'Reilly logo

Amazon Hacks by Paul Bausch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Publish Your Amazon Reviews on Your Site

With a little screen scraping, you can gather all the reviews you’ve posted to Amazon and publish them on your own web site.

If you’ve contributed reviews to Amazon and also have your own space on the Web, you might want to gather your reviews together and make them available to readers of your site. With your Amazon ID [Hack #43] in hand, you can link directly to a page on Amazon that lists all of your reviews:

http://www.amazon.com/exec/obidos/tg/cm/member-reviews/-/insert Amazon ID

If you want to take it a step further, you can use some regular-expression pattern matching to grab your reviews with one request and format them for your site.

The Code

The following ASP script requires your Amazon ID. Create a file called my_reviews.asp and enter the following code:

<% Const AmazonID = "insert Amazon ID" %>
<html>
<head>
    <title>My Amazon Reviews</title>
</head>

<body>
<%
strURL = "http://www.amazon.com/exec/obidos/tg/cm/member-reviews/-/" & _
          AmazonID & "/t/"
Set xmlhttp = Server.CreateObject("Msxml2.SERVERXMLHTTP")
xmlhttp.Open "GET", strURL, false
xmlhttp.Send(Now)
strContent = xmlhttp.responseText
Set xmlhttp = Nothing

Set objRegExpr = New regexp
objRegExpr.Pattern = "<a [^>].*detail/-/(.*?)/[^>].*><b>(.*?)</b>[\s\S]*?(\[RETURN] d) out of 5 stars[\s\S]*?<b>(.*?)</b> \n(.*?)\n<br>\n(.*?)\n<br><br>" objRegExpr.Global = True objRegExpr.IgnoreCase = True Set objMatches = objRegExpr.Execute(strContent) If objMatches.Count = 0 Then response.write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required