1

通常我会使用 fil_get_contents 来获取某个页面的 html 结构,但是对于一个特定的站点,我已经尝试了所有我得到的而不是 html 结构是这样的字符:

J��t��`$ؐ@������iG#)�*��eVe]f@�흼

有谁知道它可能是什么?我想知道该站点有一个保护系统,可以检测请求是由真实用户还是由 php 脚本发出的,在第二种情况下它会显示这个。

我已经使用 curl 来获取页面和指定的浏览器代理,但我想我应该通过使用 curl cookie 或更多来更进一步......

我使用的功能(卷曲版):

function getPage($url) {

    $proxies = array();
    $proxies[] = 'proxies here';


    if (isset($proxies)) {
        $proxy = $proxies[array_rand($proxies)];
    }


    $ch = curl_init();

    $header = array(
        'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12',
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language: en-us,en;q=0.5',
        'Accept-Encoding: gzip,deflate',
        'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
        'Keep-Alive: 115',
        'Connection: keep-alive');

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $result = curl_exec($ch);

    return $result;
    curl_close($ch);
}

任何帮助将不胜感激。

4

1 回答 1

-1

您正在处理iconv函数的字符编码可能会对您有所帮助。

于 2014-07-02T11:14:22.737 回答