首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

怎么获取远程网页的html代码,file_get_contents不起作用

2012-06-08 
如何获取远程网页的html代码,file_get_contents不起作用远程地址:http://rate.taobao.com/member_rate.htm

如何获取远程网页的html代码,file_get_contents不起作用
远程地址:http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list



通过浏览器可以得到,但是通过file_get_contents这个函数却为空,别的还有什么办法?另外得到的数据看着有点像json,但是用json_decode却不能将它转化为数组,求将得到的数据转换数组的方法

[解决办法]
那是js种的json和php的json有点区别,用jQuery获取:

JScript code
$.getJSON("http://rate.taobao.com/member_rate.htm?content=1&result=0&from=rate&user_id=281461646&identity=1&rater=0&direction=0&timeLine=-7&callback=shop_rate_list", function(json){  alert("JSON Data: " + json);});
[解决办法]
PHP code
$con= file_get_contents($url);$con= preg_replace('/shop_rate_list\((.*)\)/s','$1',$con); print_r(json_decode(iconv('gbk','utf-8',$con),true)); 

热点排行