$path="http://www.baidu.com/s?wd=qq";
$html=file_get_contents($path);
echo $html;
什么都没有!
为什么百度的这个不能读取?
各位有什么好的办法?

解决方案 »

  1.   

    我试了也不稳定,不过我换了一个方法.
    $fp = fsockopen("www.baidu.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        die($error->show_error($lang[failure],'指定的参数格式错误'));
    } else {
        $out = "GET /{$L}pv/{$cid}d.html HTTP/1.1\r\n";
        $out .= "Host: www.enf.cn\r\n";
        $out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12\r\n";
        $out .= "Connection: Close\r\n\r\n";
        
        fwrite($fp, $out);
        $i=1;
        while (!feof($fp)&&$i<1000) {
            $c.= fgets($fp, 1024);
            $i++;
        }
        fclose($fp);
    }