cURL Backlink Checker,没有回复

时间:2013-08-17 11:57:17

标签: php curl hyperlink

好的,所以我正在制作一个反向链接检查器,我有以下代码:

 $url = strip_tags($_POST['domain']);
$url = str_ireplace('www.','http://', $url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;

$result1 = file_get_html('https://www.google.com/search?q='. urlencode($url).'');

$getResults1 = $result1->find('div[id=resultStats]', 0)->innertext;
$getResults1 = str_replace("About ", "", $getResults1);
$getResults1 = str_replace(" results", "", $getResults1);
$getResults1 = str_replace(",", "", $getResults1);

echo "About".$getResults1;

问题是我得不到任何回报

echo "About".$getResults1;

回应结果

1 个答案:

答案 0 :(得分:0)

尝试我以前用过的这个功能:

function getPage ($url)
{
    $url = 'http://www.google.com/search?q='.urlencode($url);
    if (function_exists('curl_init')) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
        curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com/search?hl=en&q=google&btnG=Google+Search');
        return curl_exec($ch);
    } else {
        return file_get_contents($url);
    }
}

$html = getPage("http://stackoverflow.com/");

preg_match('/([0-9\,]+) results<nobr>/si', $html, $match);
$value = $match[1] ?: 0;

echo $value;