PHP怎么获取指定网页源码?
我用了file, file_get_contents, curl等方法,发现只能打开自己网站的源码,别的网站baidu.com sina.com.cn统统都获取不了。。不知道是怎么回事比如用的 file_get_contents,下面这样应该是能成功的啊。。怎么我一试就不行。。
$str = file_get_contents($url);另外服务器php.ini是打开了allow_url_fopen的。。PHP源代码

解决方案 »

  1.   

    那么你
    echo file_get_contents('http://bbs.csdn.net/topics/390455646?page=1#post-394461296');都能看到什么?
      

  2.   


    什么都没有。。拿strlen取长度也是0我用的Awardspace上的虚拟空间主机。。是不是除了allow_url_fopen有什么会限制读取?
      

  3.   

    可能是有些限制吧,用 phpinfo() 看看