範例網站:http://web.de捲曲HTTP代碼爲404
在瀏覽器中:沒有任何問題
在捲曲工作:還給錯誤404沒有找到。
捲曲選項
$cookie_file_path = "/adm/cookie.txt";
$header[0] = "Accept: text/html,application/xhtml+xml,application/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: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3";
$header[] = "Pragma: ";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_POST, 0);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSLVERSION,3);
curl_setopt ($ch, CURLOPT_ENCODING, "");
curl_setopt ($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt ($ch, CURLOPT_NOBODY, 0);
curl_exec($ch);
可能是什麼原因呢?
也許$ url是空的?? ...在這一行curl_setopt($ ch,CURLOPT_URL,$ url); – Hackerman
不,不是。當我回應它時,它給了我一個URL。另外,當我在終端中使用cURL時,它也可以工作 – Musterknabe