I have just started with php..
I would like to do some web scrapping..
I want to get the search results of goodreads.com in a text file.. So i need to get the search result in some object format so that it can be easily processed..
Sample code to get the google.com search results..but the same to not applicable for goodreads.com as such.. what should be done to make it work? your answers are appriciated!!
<?php
$query = "java%20book";//to search for 'java book'
$url = "http://ift.tt/QuVdD6".$query;
$body = file_get_contents($url);
$json = json_decode($body);
for($x=0;$x<count($json->responseData->results);$x++){
echo "<b>Result ".($x+1)."</b>";
echo "<br>URL: ";
$myvar=$json->responseData->results[$x]->url;
$hi=" hi";
echo $myvar;
echo "<br>VisibleURL: ";
echo $json->responseData->results[$x]->visibleUrl;
echo "<br>Title: ";
echo $json->responseData->results[$x]->title;
echo "<br>Content: ";
echo $json->responseData->results[$x]->content;
echo "<br><br>";
}
?>
Aucun commentaire:
Enregistrer un commentaire