0

我知道以前在这里问过类似的问题,但是在搜索了该站点之后,似乎没有找到解决方案。

我正在使用以下选项通过代理 curl 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] => ) 

可能是我在代理上的访问设置/网络拦截器吗?

有任何想法吗?谢谢

4

0 回答 0