Rumah > Artikel > pembangunan bahagian belakang > php curl采集的提示403异常
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的问题。该如何采集这个页面