All pastes #539186 Raw Edit

Link Count

public php v1 · immutable
·published 2007-06-05 06:29 UTC
rendered paste body
<?php/** By Dbyt3r* Function: take a keyword and get the top X results' link count* Variables to edit: $keyword & $numberOfResults*//* Configure -- */$keyword = "[%yourkeyword%]";$numberOfResults = 20;/* Stop right f*ing here */function get($_url){	$ch = curl_init($_url);	curl_setopt($ch,CURLOPT_RETURNTRANSFER,True);	$res = curl_exec($ch);	curl_close($ch);	return $res;}function get_multi($_urls){	$mh = curl_multi_init();	foreach ($_urls as $i => $url) {       		$conn[$i]=curl_init($url);       		curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string        		curl_multi_add_handle ($mh,$conn[$i]);	}	do { $n=curl_multi_exec($mh,$active); } while ($active);	foreach ($_urls as $i => $url) {       		$res[$i]=curl_multi_getcontent($conn[$i]);       		curl_multi_remove_handle($mh,$conn[$i]);       		curl_close($conn[$i]);	}	curl_multi_close($mh);	return $res;}$_url = "http://www.google.com/ie?num=$numberOfResults&q=" . urlencode($keyword);$res = get($_url);preg_match_all("@<a\s+title=\".+?\"\s+href=(.+?)>@",$res,$matches);foreach($matches[1] as $match){	$_urls[] ="http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=" . rand(1,1000) . "&query=" .		urlencode($match) . "&results=1";}$res = get_multi($_urls);foreach($res as $i=> $_res){	preg_match("@totalResultsAvailable=\"(\d+)\"@",$_res,$match);	echo $matches[1][$i] . "\t\t\t" . $match[1] . "\n";}?>