-1
我需要解析网站http://klassprof.org/。但是有Cloudflare反DDOS保护。我如何解决这个问题? 我从Chrome浏览器复制了Cookie并将其设置在我的卷曲功能中,但它没有帮助。在这里我的功能:访问前检查您的浏览器
function get_web_page($url)
{
$uagent = "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_PROXY, "46.242.85.129:8081");
curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_COOKIE, "PHPSESSID=f9sofurv85om9qq91rpt3rgkh2;__cfduid=db1ddd834ca4ec4c1ebdff85f5b00f7e51492411567;cf_clearance=33fc7099c3c9c000dc60be8e546e09182bb9df68-1492411571-1800");
//curl_setopt($ch, CURLOPT_COOKIEFILE,"d://coo.txt");
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
/*foreach($header as $key=>$value){
echo $key.' -- > '.$value.'<br>';
}*/
curl_close($ch);
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
我运行此代码,但它并没有帮助 – Baurzhan
尝试从Chrome的Cookie然后再将其粘贴到代码中以刷新cookie。 –
我现在做了,但没有任何反应,可能是因为用户代理是歌剧吗? – Baurzhan