我过去已经解决了这个问题,但我绝对不记得是如何解决的。
所以,我正在尝试使用代理将网页获取到我的服务器。
这是代码:
function curlFile($url,$proxy_ip,$proxy_port,$loginpassw)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $loginpassw);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
$data = curl_exec($ch);
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
}
print_r(curl_getinfo($ch));
print_r(curl_error($ch));
print_r($data);
curl_close($ch);
return $data;
}
它当前输出的只是:
卷曲错误:无法连接到 hostArray ( [url] => http://www.drkameleon.com [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.007872 [namelookup_time] => 0.007537 [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 ) 无法连接到主机
那么,有什么想法吗?可能出了什么问题?