[GET] PHP google results checker

5VM5UN6

Registered Member
Joined
Jun 18, 2009
Messages
51
Reaction score
9
Recently i've made myself a script to check google results for given keywords. Thought it may be useful to somebody.

Script requires cURL to work.

Code:
<?php
function GoogleResults($URL)
{
	$ch=curl_init();
	curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q='.urlencode($URL));
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$output = curl_exec($ch);
	curl_close($ch);
	preg_match('/of \<b\>([0-9\,]+)\<\/b\>/si', $output, $m);
	
	if(isset($m[1]))
		return $m[1];
	preg_match('/of about \<b\>([0-9\,]+)\<\/b\>/si', $output, $m);
	if(isset($m[1]))
		return $m[1];
}
?><html>
<body>
<div>
<?php
$list=null;
if(isset($_POST['submit']))
{
	$keywords=explode("\n", $_POST['body']);
	echo "<table><tr><td>Keyword</td><td>Broad</td><td>Exact</td><td>In title</td></tr>";
	foreach($keywords as $value)
	{
		$value=trim($value);
		if($value)
		{
			echo "<tr><td>".$value."</td><td><a href='http://www.google.com/search?q=".urlencode($value)."'>".GoogleResults($value)."</a></td><td><a href='http://www.google.com/search?q=".urlencode("\"".$value."\"")."'>".GoogleResults("\"".$value."\"")."</a></td><td><a href='http://www.google.com/search?q=intitle:".urlencode("\"".$value."\"")."'>".GoogleResults("intitle:\"".$value."\"")."</a></td></tr>\n";
			$list.=$value."\n";
		}
	}
	echo "</table>";
}
?>
</div>
<form action="" method="post">
<textarea name="body" rows="10" cols="40"><?php echo $list;?></textarea><br/>
<input type="submit" name="submit"/>
</form>
</body>
</html>
 
but any difference between normal search and this script search?
 
Script takes mulptiple keywords and checks them for broad, quoted and in title matches.
 
Back
Top