YQL获取天气

$(function () {
$.getJSON("http://query.yahooapis.com/v1/public/yql?callback=?", {
q: "select * from json where url='http://m.weather.com.cn/data/101210101.html'",
format: "json"
}, function (data) {
if (data.query.results) {
var result = JSON.stringify(data.query.results);
var obj = eval('(' + result + ')');
alert(obj.weatherinfo.temp1);
}
});
});

posted @ 2013-12-31 16:01  王者杂货铺  阅读(227)  评论(0编辑  收藏  举报