Heim  >  Artikel  >  Backend-Entwicklung  >  php curl采集的提示403异常

php curl采集的提示403异常

WBOY
WBOYOriginal
2016-06-13 11:15:431223Durchsuche

php curl采集的提示403错误
function get_music_detail_url($url){

if(empty($url)) return array();

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);       
curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
$somecontent = curl_exec($ch); 
curl_close($ch); 
return $somecontent;
}
$re = $client->get_music_detail_url("http://music.douban.com/subject/1756577/");
print_r($re);

提示以下错误

403 Forbidden
nginx

请问如何解决才能正常采集呢。遇到提示403的问题。该如何采集这个页面


------解决方案--------------------
经测试,没有发现你说的现象
不过页面数据中有 js 操控,得到的可能不是你需要的东西
------解决方案--------------------
同一段代码,有人403,有人正常,这种情况针对IP(范围)限制的可能性极高
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn