php抓取天气预报接口数据问题,求指点 json天气预报 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $url = 'http://www.weather.com.cn/data/cityinfo/101070101.html';$s = file_get_contents($url);print_r(json_decode($s, true));Array( [weatherinfo] => Array ( [city] => 沈阳 [cityid] => 101070101 [temp1] => 10℃ [temp2] => -2℃ [weather] => 多云 [img1] => d1.gif [img2] => n1.gif [ptime] => 08:00 )) httpGetRequest无需理会,反正目的就是把文本抓下来,只是用了什么手段而已,你完全可以自写直接获取就按版主给的file_get_contents,想省点流量就用curl或者socket发送压缩请求先用 file_get_contents 把工作完成了,等有时间学习了curl, socket...再回头优化吧 你贴的代码中 $info 就是你得到的数据 版主就是版主,十分感谢!还有感谢snmr_com的优化建议! 这个接口已经不更新了,获取的数据不对http://club.weather.com.cn/thread-555402-1-1.html 请教PHP表单post 提交 apache 以及 php配置问题 代码求效率优化 2011年4月;用正则怎么写?????? php数据库连接问题 PHP在登录系统中,不管输入任何登录子页网址,都必须先登陆主页 用mysql repair 后 不见了的数据有没有办法找回来哟? 三级菜单如果对最后一级进行判断 请教一个正则表达式的问题 求一个sql语句 求指教 安装了MYSQL7.0.9,网站程序怎么检测不到? 这是什么数据格式?
$s = file_get_contents($url);
print_r(json_decode($s, true));Array
(
[weatherinfo] => Array
(
[city] => 沈阳
[cityid] => 101070101
[temp1] => 10℃
[temp2] => -2℃
[weather] => 多云
[img1] => d1.gif
[img2] => n1.gif
[ptime] => 08:00
))
直接获取就按版主给的file_get_contents,想省点流量就用curl或者socket发送压缩请求
先用 file_get_contents 把工作完成了,等有时间学习了curl, socket...再回头优化吧