我试图向基于https的网址发出curl请求。但似乎没有回来.. 我测试了许多适用于非https的代理。
$att = "cookie.txt";
$ip = "121.14.138.56:81";
$curl = curl_init("https://www.att.com");
curl_setopt($curl, CURLOPT_PROXY, $ip);
curl_setopt($curl, CURLOPT_COOKIEJAR, $att);
curl_setopt($curl, CURLOPT_COOKIEFILE, $att);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/27.0.1453.94 Safari/537.36");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 50);
curl_setopt($curl, CURLOPT_TIMEOUT, 50);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$reply = curl_exec($curl);
curl_close($curl);
echo $reply;
答案 0 :(得分:0)
似乎这段代码正常运行。注意:只有一些代理支持https ..
$proxy = "205.221.221.111:8080";
$curl = curl_init("https://www.att.com");
if (isset($proxy)) {curl_setopt($curl, CURLOPT_PROXY, $proxy);}
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_COOKIEJAR, $att);
curl_setopt($curl, CURLOPT_COOKIEFILE, $att);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/27.0.1453.94 Safari/537.36");
curl_setopt($curl, CURLOPT_COOKIE, 'cookie.txt');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$reply = curl_exec($curl);
curl_close($curl);
var_dump(curl_getinfo($curl));
echo $reply;