• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » Script to Scraping Amazon Product in PHP with Amazon API

Script to Scraping Amazon Product in PHP with Amazon API

By Sigit Prasetya Nugroho ∙ August 5, 2014 ∙ PHP ∙ 3 Comments

Share : TwitterFacebookTelegramWhatsapp

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 dont 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

Table of Contents

  • 1  To build Scraping Amazon script, you need to prepare. 
    • 1.1 1. Get your amazon public key and amazon private key from aws.amazon. Read here for more info.
    • 1.2 2. Build Function in PHP to get Product Advertising API URL
    • 1.3 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 🙂 .

 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.

 

scraping amazon product - public key and private key

Related Articles :

  • How to Create Autocomplete Amazon Keyword Suggestion With Jquery
  • Easy Get XML Amazon API Data with My Amazon_Class
  • Easy Get ASIN with My Amazon Asin Grabber Class

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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";
ksort($params);
$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;
return $request;
}

Call that function with this syntax below

1
2
3
4
5
6
7
8
9
10
11
$parameters=array(
'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 

Script to Scraping Amazon Product in PHP with Amazon API

 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.

You can combine with my ASIN GRABBER SCRIPT to get a reliable program. See and try my example here.

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 🙂 .

Another PHP Related Post :

  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen
  • How To Create Custom Class In Laravel 5.5 For Beginners

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Comments

  1. Avatar for FrankFrank says

    September 28, 2015 at 5:09 pm

    Thanks for this article. I am still stumped on how to get the public/private keys. I ‘thot’ I had them, but they appear to be certificate signature files (20 lines), not a normal 20-40 character string.
    I got them here:
    https://console.aws.amazon.com/iam/home?region=us-west-2#security_credential

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      September 29, 2015 at 8:00 am

      sory i dont understand what you mean ? but i created new public and private key from your link, it is successful

      Reply
  2. Avatar for Sahil AhlawatSahil Ahlawat says

    January 28, 2018 at 6:15 pm

    can this script be used to fetch all the amazon products?

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      January 29, 2018 at 1:15 am

      This script can fetch the amazon products that are allowed by amazon API

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (7) Publisher Tips (5) react (3) Reactjs (7) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) widget (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2021 Seegatesite.com