我使用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);