在curl函数问题中传递冒号

时间:2015-04-06 22:19:02

标签: php curl

我有这个功能:

function file_get_contents_curl($url) {
    $ch = curl_init();
    $ua = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_USERAGENT, $ua); 


    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}

现在我有一个奇怪的问题:我正试图在谷歌搜索 使用" inurl:example.com",像这样:

$email =  $_GET["email"];
$in = "inurl:example.com+" . $email;
$in = str_replace(' ','+',$in);
$url  = 'http://www.google.com/search?hl=en&q='.$in;

每次我得到0结果。

然而,当我摆脱" inurl:"并用其他一些替换它 条件,像这样:

$in = "example.com+" . $email;

效果很好,我看到了结果。

关于COLON的一些事情(" inurl:")会给file_get_contents_curl函数带来麻烦。

我在file_get_html函数中尝试了相同的inurl:string(而不是file_get_contents_curl)

$html = file_get_html($url);

完全没有问题。

有什么想法吗?

修改

$in = "+inurl:pastebin.com";
$in = str_replace("%3A",":",$in);

(NOT)解决了这个问题。

修改 有时它有效,有时不行。 所以它与谷歌阻止/限速相关 和那样的东西。

非常感谢。

0 个答案:

没有答案
相关问题