get searching data from google on localhost

Hi friends,
Try this to get search data on your local host.

<?php
$text = $_POST['search'];

?>

<form action="searchbygoogle.php" method="POST">
<input name="search" type="text" value="<?= $text;?>" />
<input type="submit" value="Search" />
</form>




if ($_POST['search']==""){
echo "No search data found";
}
else{
$query = file_get_contents("http://www.google.com/search?q=".urlencode($_POST['search'])."&hl=en&ie=UTF-8&filter=2");

//needs to be added with more queries
$replace_array = array('/\n/','/(.*)<\/head>/','/(.*)
/','/
(.*)/');
//pregraplacing unneeded parts
$results = preg_replace($replace_array, '', $query);
echo $results;
}


?>
</div>


Comments

Popular posts from this blog

ubuntu package installation

Drupal Bootstrap Database

How to fix 500 internal privoxy error