我尝试使用代理连接每个Curl的SSL页面。不幸的是我收到错误:
代理CONNECT已中止
当我尝试连接而没有代理时,一切正常。 这个错误的原因是什么?
const COOKIE_FILE = 'cookie.txt';
private $curlOptions = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks
CURLOPT_COOKIESESSION => 1,
CURLOPT_SSL_VERIFYHOST => false
//CURLOPT_HTTPHEADER => array('Content-Type: text/html'),
//CURLOPT_COOKIESESSION => true,
//CURLOPT_COOKIEJAR => 'cookie.txt',
//CURLOPT_COOKIEFILE => 'cookie.txt'
);
public function grab_page($site, $proxy=0){
$ch = curl_init();
if($proxy)
{
$proxyCon = new Proxy();
$proxyCon->setProxy();
curl_setopt($ch, CURLOPT_PROXYPORT, $proxyCon->port);
curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
curl_setopt($ch, CURLOPT_PROXY, $proxyCon->ip);
//exit('s'.$proxyCon->ip.':'.$proxyCon->port);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(CurlService::COOKIE_FILE));
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(CurlService::COOKIE_FILE));
curl_setopt($ch, CURLOPT_URL, $site);
curl_setopt_array($ch, $this->curlOptions );
ob_start();
return curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
}