Yeah, I already checked the discussion groups, but couldn't find the answer.
Right now i'm using this piece of code:
Code: Select all
function getBookMarks($url, $site) {
$url="http://www.google.com/search?num=10&hl=en&safe=off&q=site:$site%20$url&btnG=Search";
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init($url);
//curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
//curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookie-jar.txt");
//curl_setopt($ch, CURLOPT_COOKIEFILE, "./cookie-jar.txt");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
$data = curl_exec($ch);
curl_close($ch);
if(preg_match("/did not match any documents/i", $data)) {
return(0);
}
$spl = explode("<div id=resultStats>", $data);
$spl2 = explode(" results", $spl[1]);
$ret = trim($spl2[0]);
if(strlen($ret)==0) {
return(0);
} else {
return($ret);
}
}
Bassicly scraping the total results from the website, but i figured it would be easier / faster when i used the AJAX api