php 使用curl 代理访问报错:Operation timed out after 0 milliseconds with 0 out of 0 bytes received

来源:互联网 发布:xmind中文破解版 mac 编辑:程序博客网 时间:2024/06/08 08:41

对应的curl代码如下:
出现报错Operation timed out after 0 milliseconds with 0 out of 0 bytes received

$ch = curl_init();curl_setopt ($ch, CURLOPT_PROXY, $proxy);curl_setopt ($ch, CURLOPT_URL, $url);curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");curl_setopt ($ch, CURLOPT_HEADER, 1);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt ($ch, CURLOPT_TIMEOUT, 120);$result = curl_exec ($ch);curl_close($ch);return $result;

或者

$curl=curl_init();curl_setopt($curl,CURLOPT_URL, "https://www.lvtao.net");curl_setopt($curl,CURLOPT_HEADER,1);curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);curl_setopt($curl,CURLOPT_POST,1);curl_setopt($curl,CURLOPT_PROXYTYPE,CURLPROXY_SOCKS5);//使用了SOCKS5代理curl_setopt($curl, CURLOPT_PROXY, "ip:1080");  $data = array('user' => "geek", 'password' => 'fuck');curl_setopt($curl, CURLOPT_POSTFIELDS, $data);//curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);如果是HTTP代理//curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');cookie你懂的$request = curl_exec($curl);//var_dump($request);curl_close($curl);

可能是ssl版本问题

$ch=curl_init();curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_SSLVERSION, 3);

curl 、wget使用代理

命令使用代理

wget/curl 都支持使用代理

wget -e “http_proxy=10.1.4.43:8080″ proxy.mimvp.com

curl -x 10.1.4.43:8080 proxy.mimvp.com

环境变量使用代理

curl、wget也支持通过环境变量http_proxy来设置要使用的代理服务器, 如下:

这个帐号使用的代理服务器
http_proxy=”http://mycache.mydomain.com:3128″
export http_proxy

如果代理服务器需要用户名和密码,只要将它们加入 URL。

例如:用户名 myuser,密码 mypwd,添加设定:

这个帐号使用的代理服务器和用户名/密码
http_proxy=”http://myuser:mypwd@mycache.mydomain.com:3128″
export http_proxy

然后直接wget proxy.mimvp.com 或者curl proxy.mimvp.com

阅读全文
0 0
原创粉丝点击