[英]curl with multiple proxies working on local server but not on live server
我的这段代码在我的本地服务器上运行正常,但在实时服务器上却无法运行。
我正在尝试报废而不会被阻止。
如果代理服务器被远程服务器阻止,那么它如何在我的本地服务器上运行?
function curl_se($set_url,$proxy){
$ch = curl_init($set_url);
//set options
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; //browsers keep this blank.
//set options
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
echo "<pre>";
print_r(curl_getinfo($ch));
echo "</pre>";
if(curl_errno($ch))
return false;
else
return $result;
}
在每个curl请求上循环一个代理。
$proxy = array(
"91.83.216.186:8081",
"190.116.88.11:8080",
"117.102.9.116:8080",
"188.165.4.38:3128",
"187.120.209.10:8080",
"190.186.50.32:3128",
"190.108.83.30:8080",
"190.130.230.149:8080",
"130.180.18.24:8275",
"178.33.181.120:8080"
);
在实时服务器上,我收到卷曲错误7(CURLE_COULDNT_CONNECT)
我被困住了,这是相同的代码,相同的URL在本地可以正常工作。
更新:我发现这与代理有关。 我尝试了数百个,但是没有一个在实时服务器上工作,出现curl错误7; 也尝试了其他网站网址。 而相同的代理服务器和URL在我的本地服务器上运行。
尝试使用代理。 检查此处(codepad.viper-7.com/xzm8Au)您的服务器运行正常。
使用匿名代理时,远程(目标)服务器无法看到或阻止您的真实IP。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.