-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