PHP Script for Amazon

blackjack

Regular Member
Joined
Nov 23, 2007
Messages
276
Reaction score
53
Hi

I am not sure if this is the correct place to ask this question. Please move it if this is not correct category.

I am looking for a PHP script for Amazon which searches based on Asin Number not search keyword. Is there any thing link this available.

The basic things are

1. Create a config.php file with Amazon site selection, Amazon dev id, Amazon affiliate ID and Amazon ASIN

2. Use PHP to get the following information Product Name, Price, Description, Image and customer review. Then populate a template with that information.

Thanks for your time.
 
I'd be interested in something like this myself....I'd also like to know the best amazon script to create profits with?

Thanks all
 
PHP:
<?php
$c = curl_init();

curl_setopt($c, CURLOPT_URL, 'http://www.amazon.co.uk/dp/0261102389/');//connect to amazon site
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_VERBOSE, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER,1);
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686;pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
curl_setopt($c, CURLOPT_ENCODING, 'gzip');
curl_setopt($c, CURLOPT_ENCODING, 'deflate');
curl_setopt($c, CURLOPT_ENCODING, '');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);

$page = curl_exec($c);


$title = explode('<span id="btAsinTitle"',$page);
$title = explode('>',$title[1]);
$title = explode('</span>',$title[1]);


echo $title[0];
?>

This code take only title but you can do the same with description,price etc.
You only need for this ASIN database. Ofcourse you can use brutal method for this:
http://www.amazon.co.uk/dp/[B]0000000001[/B]
http://www.amazon.co.uk/dp/[B]0000000002[/B]
http://www.amazon.co.uk/dp/[B]0000000003[/B]
etc
but you will get ban for ip adress shortly

tomorrow i will give you better code


Click thanks if I helped ;)
 
Thanks. I have no idea how does this code work? Look forward to your better code tomorrow.

Thanks
 
PHP:
<?php
//----------------- CONECT SECTION
function connect($url)
{

	$a = curl_init();
	curl_setopt($a, CURLOPT_URL, "$url");//connect to amazon site
	curl_setopt($a, CURLOPT_HEADER, 1);//send header
	curl_setopt($a, CURLOPT_VERBOSE, 1);
	curl_setopt($a, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($a, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686;pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');//send usragent
	curl_setopt($a, CURLOPT_ENCODING, 'gzip');
	curl_setopt($a, CURLOPT_ENCODING, 'deflate');
	curl_setopt($a, CURLOPT_ENCODING, '');
	curl_setopt($a, CURLOPT_FOLLOWLOCATION, 1);
	global $page;
	$page = curl_exec($a);//put html code into $page variable
}	
//-----------------END CONECT SECTION

connect('http://www.amazon.co.uk/dp/0261102389');//You should take this url from database 

//-----------------START TAKING DATA
/////////////////////////////////////////////////////////////////////////////
//example
//		$text=ABCD;
//		$title = explode('A',$text);			satrt searching after A
//		$title = explode('B',$title[1]);			B is left limit
//		$title = explode('D',$title[1]); 			D is right limit
//		echo $title[0];					this will show C
////////////////////////////////////////////////////////////////////////////

$title = explode('<span id="btAsinTitle"',$page);//start search title from here
$title = explode('>',$title[1]);//Take data from here
$title = explode('</span>',$title[1]);//to here 


$price = explode('<span class="price"',$page);
$price = explode('>',$price[1]);
$price = explode('</span>',$price[1]);


$description = explode('<h2>Product Description</h2>',$page);
$description = explode('<div class="content">',$description[1]);
$description = explode('<img src=',$description[1]);

//Now we can save this in database
//	EXAMPLE
//	$sql = mysql_connect (localhost, 'root', 'krasnal');
//	$dbase=mysql_select_db('amazon_db');
//	$query = "INSERT INTO `amazon` (`Id`, `Title`, `Price`, `Descyprion`) VALUES ('', '$title[0]', '$price[0]', '$description[0]')";
//	$save = mysql_query($query);
?>

For now i have no idea how to take all image's and customer review's because his number is not constant.
Certainly it is possible to make it, but now i don't have idea how to check how many it is.
regards
 
Back
Top