Well, this time I will share about how to scraping amazon products using Amazon API. Many new amazon players are still confused how amazon API worked to scraping amazon product. I don
t suggest you to do the screen scraping, Because is not permissable. Scrap amazon products using the API is a legal way. Beside legal, its more easy to use than screen scraping.
Who still confused about scraping amazon products using APIs can see the video snippet below
To build Scraping Amazon script, you need to prepare.
1. Get your amazon public key and amazon private key from aws.amazon. Read here for more info.
2. Build Function in PHP to get Product Advertising API URL
I got the function from this site, visit there if you need to learn more. I do a little modification to be easy to use.
function aws_signed_request($region, $params, $public_key, $private_key)
$method = "GET";
$host = "ecs.amazonaws.".$region;
$uri = "/onca/xml";
$params["Service"] = "AWSECommerceService";
$params["AWSAccessKeyId"] = $public_key;
$params["Timestamp"] = gmdate("Y-m-d\TH:i:s\Z",time()); //may not be more than 15 minutes out of date!
$params["Version"] = "2009-03-31";
$canonicalized_query = array();
foreach ($params as $param=>$value)
$param = str_replace("%7E", "~", rawurlencode($param));
$value = str_replace("%7E", "~", rawurlencode($value));
$canonicalized_query = $param."=".$value;
$canonicalized_query = implode("&", $canonicalized_query);
$string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, True));
$signature = rawurlencode($signature);
$request = "http://".$host.$uri."?".$canonicalized_query."&Signature=".$signature;
Call that function with this syntax below
'Operation' =>'ItemLookup' ,
'ItemId' =>$sku , // change $sku with ASIN code
'AssociateTag' =>$tag, //Your AssociateTag url
'ResponseGroup' =>'Large' , //Small, Medium, Large or SellerListing
$public_key =$pub_key; // Change with your public key
$private_key=$priv_key; // Change with your private key
$ext='com'; //extension of server, see data.php
ksort($parameters); // To shorting variable $parameters
$A=aws_signed_request($ext,$parameters,$pub_key,$priv_key); // Call aws_signed_request
The results of the $A variable is you will get Product Advertising API URL like
If you get results as above, you've managed to get Amazon product XML. With a few additions and looping statements in the script above you will get thousands of Amazons data , within a matter of hours.
For scraping amazon xml data and how to arrange the data so that look elegant, i will discuss on the next article, if you have a question please comment below 🙂 .
Latest posts by Sigit Prasetya Nugroho (see all)
- Reviews For The7 Responsive Multi Purpose WordPress Theme - June 17, 2017
- Superfast Theme – The Fastest WordPress Theme For Adsense - June 3, 2017
- Tips Write A Good And SEO Friendly Blog Post – Mandatory For Blogging - June 1, 2017