Jump to content

Google Results reading


MiCR0

Recommended Posts

I am trying to work out how to work out rank on google results.

 

I so far have the results of the first page however can not work out how to get to the next page.

 

 

<?phpfunction google_search_api($args, $referer = 'google.php', $endpoint = 'web'){$url = "http://ajax.googleapis.com/ajax/services/search/".$endpoint;if ( !array_key_exists('v', $args) )	$args['v'] = '1.0';$url .= '?'.http_build_query($args, '', '&');$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);// note that the referer *must* be setcurl_setopt($ch, CURLOPT_REFERER, $referer);$body = curl_exec($ch);curl_close($ch);//decode and return the responsereturn json_decode($body);}$rez = google_search_api(array(	'q' => 'test',));print_r($rez);?>

 

 

Now I working off the http://code.google.com/intl/en/apis/ajaxsearch/documentation/reference.html#_class_GSearch

 

What I am trying to do is build is http://www.further.co.uk/tools/search-position-check/

 

I am almost there with doing it with bing results

 

 

function bingrank($keyword,$domain){$rank = '0';$urls = array();for($i=0;$i<10;$i++){	$rn=$i=='0'?'':$i;	$query = "http://www.bing.co.uk/search?q=".urlencode($keyword)."&first=".$rn."1";	$result_page = file_get_contents($query);	preg_match_all('/class="sb_tlst"><h3><a href="(.*?)"/',$result_page,$matches);	foreach($matches[1] AS $url){		$urlst = str_replace('www.', "", preg_replace('(^http://|/$)','',$url));		$urlsz = explode("/", $urlst);		$urls[] = $urlsz[0];		if ($urlsz[0] == $domain){			return $i+1;			}	}}return 'N/F';}

 

 

Any advice or help would be great.

 

Link to comment
https://forums.phpfreaks.com/topic/214514-google-results-reading/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.