我知道之前已经在这里询问过类似的问题,但在搜索完网站后,似乎找不到任何解决方案。
我正在使用以下选项通过代理来卷曲yahoo.com或任何网站(我已经尝试了一些)。 连接似乎很好,因为它返回标头。问题是它只返回标题。我希望能够检索的是源html。
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "myusername:mypassword");
[编辑1] 我使用curl_exec来获取数据:
$content=curl_exec($ch);
echo $content;
[编辑2] 用户代理如下:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
[编辑3] 这是我调用curl_getinfo:
时返回的内容Array ( [url] => http://www.yahoo.com/
[content_type] => [http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array ( )
[primary_ip] =>
[primary_port] => 0
[local_ip] =>
[local_port] => 0
[redirect_url] => )
可能是代理上的访问设置/网络拦截器吗?
有什么想法吗? 感谢