我要去一个有cURL和阅读的网站。我的某些网站列表中出现“错误请求”错误。 例如,
“https://www.iett.istanbul/tr/main/hatlar/1/KİRAZLITEPE-ACIBADEM-KADIKÖY-İETT-Otobüs-Sefer-Saatleri-ve-Durakları”->成功
“ https://www.iett.istanbul/tr/main/hatlar/2/BOSTANCI-HAREM-İETT-Otobüs-Sefer-Saatleri-ve-Durakları” --->错误
MyCode:
$hatUrl = str_replace('','%20',$link);
$ckfileHat = tempnam("/tmp", "CURLCOOKIE");
$headers = array(
'Vary: Accept-Encoding',
'Connection: keep-alive',
'Content-type: text/html; charset=UTF-8'
);
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.9.2.12) Gecko/20101026
Firefox/3.6.12 (.NET CLR 3.5.30729)';
$chHat = curl_init($hatUrl);
curl_setopt($chHat, CURLOPT_HTTPHEADER, $headers);
curl_setopt($chHat, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($chHat, CURLOPT_RETURNTRANSFER, true);
curl_setopt($chHat, CURLOPT_COOKIEJAR, $ckfileHat);
curl_setopt($chHat, CURLOPT_COOKIEFILE, $ckfileHat);
curl_setopt($chHat, CURLOPT_HEADER, 1);
curl_setopt($chHat, CURLOPT_VERBOSE, 1);
curl_setopt($chHat, CURLOPT_USERAGENT, $user_agent);
$htmlHat = curl_exec($chHat);
有类似问题的人可以帮忙吗?
谢谢。