郁闷啊,php抓取页面老是无法获取结不美观仿佛是被301重定向了,怎么解决啊?

我使用file_get_contents这个函数获取 这个页面参数的时辰每次都是提醒Warning : file_get_contents( [ function.file-get-contents ]: failed to open stream: Redirection limit reached, aborting in /home/ghlin/public_html/gphone.php on line 3怎么办啊?用了curl和fopen都无效,求解决,他们说何处处事器要user_Agent,模拟出来之后也无效,怎么办?

<?php$url=' http://www.bamuyu.com/news/zixun/list_7_2.html';$content=curl_file_get_contents($url);echo $content;function curl_file_get_contents($durl){ $cookie_file = dirname(__FILE__)."/cookie.txt"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $durl); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $r = curl_exec($ch); curl_close($ch); return $r; }
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-04-19
curl 里有个设置跟年夜页面的重定向curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网