Instead of searching by Title or Artist, you can find an ASIN for a CD by using the UPC.
Almost every product has a UPC (Universal Price Code). Amazon doesn’t offer product searches by UPC through their main web site, but they do offer it for music products through their Web Services.
Following is a simple bit of JavaScript code that brings up a CD’s product detail page based on a UPC.
Tip
To run this script you’ll just need a developer’s token Section 6.4 and Internet Explorer for Windows.
Save this piece of HTML as a text file on your computer. Name it something appropriate (cd_asin.html will do nicely).
<html>
<head>
<title>Find a CD's ASIN</title>
<script language="JavaScript">
function getDetailPage(upc) {
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.Open("GET", "http://xml.amazon.com/onca/xml2?t=webservices-[RETURN]
20&dev-t=insert developer'stoken
&UpcSearch="+upc+"&mode=music&type=lite[RETURN]
&f=xml", false);
xmlhttp.Send( );
var response = xmlhttp.responseXML;
if (response.selectSingleNode("/ProductInfo/ErrorMsg")) {
alert(response.selectSingleNode("/ProductInfo/ErrorMsg").text);
} else {
var asin = response.selectSingleNode("/ProductInfo/Details/Asin")[RETURN]
.text;
document.location = "http://amazon.com/o/ASIN/" + asin;
}
}
</script>
</head>
<body>
<form>
<input name="upc" type="text" size="25">
<input type="button" value="Go"
onClick="getDetailPage(document.forms[0].upc.value);">
</form>
</body>
</html>
Get Amazon Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.