Wednesday, January 30, 2008

Image Crawling in php

<?php
$image_url = "http://www.isbnonline.com/files/b/8/3597/200/ASP-NET-2-0-Website-Programming-Problem-Design-Solution-Programmer-to-Programmer.jpg";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/jpeg");
$Imp=fopen("image/book.jpg","w");
fwrite($Imp,$image);
print $image;
?>

No comments:

Post a Comment