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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.