Json获取中国天气网天气的代码
2013-09-05 20:22
489 查看
网页特效on获取中国天气网天气的代码
var url=escape("http://m.weather.com.cn/data/101210701.html");
var cookie_info = "cookie_info";
var date = new date();
var hours=24-date.gethours()-1;
var mins=60-date.getminutes()-1;
var secs=60-date.getseconds();
date.settime(date.gettime() + (1 * hours * 60 * 60 * 1000) + (1 * 1 * mins * 60 * 1000) + (1 * 1 * 1 * secs * 1000));
var rd_cookie_info= $.cookie(cookie_info);
$(function(){
if(rd_cookie_info==null)
{
getdata(url);
}
else{
$("#weather").html(rd_cookie_info);
}
})
function getdata(url)
{
$.ajax({
type:"get",
cache: "false",
url: "ajaxget.asp教程",
data:"url="+url,
datatype: "html",
error: function(){$("#weather").html("读取失败...请刷新重试!");},
success: function(网页特效on){
var t = '('+json+')';
var result = eval(t);
var getinfo="";
getinfo+=result.weatherinfo.date_y+" ";//年月日
getinfo+=result.weatherinfo.date+" ";//农历年月日
getinfo+=result.weatherinfo.week+" ";//星期几
getinfo+="<br />";//换行
getinfo+=result.weatherinfo.city;//获取城市名称
getinfo+=" <img src="http://m.weather.com.cn/img/c"+result.weatherinfo.img1+".gif"/> "//天气图片1
getinfo+="<img src="http://m.weather.com.cn/img/c"+result.weatherinfo.img2+".gif"/> ";//天气图片2
getinfo+=result.weatherinfo.weather1+" ";//天气情况
getinfo+=result.weatherinfo.temp1;//温度
$.cookie(cookie_info,getinfo, { path: '/', expires: date });
$("#weather").html(getinfo);
}
});
}
<div id="weather" style="font-size:12px;"></div>
var url=escape("http://m.weather.com.cn/data/101210701.html");
var cookie_info = "cookie_info";
var date = new date();
var hours=24-date.gethours()-1;
var mins=60-date.getminutes()-1;
var secs=60-date.getseconds();
date.settime(date.gettime() + (1 * hours * 60 * 60 * 1000) + (1 * 1 * mins * 60 * 1000) + (1 * 1 * 1 * secs * 1000));
var rd_cookie_info= $.cookie(cookie_info);
$(function(){
if(rd_cookie_info==null)
{
getdata(url);
}
else{
$("#weather").html(rd_cookie_info);
}
})
function getdata(url)
{
$.ajax({
type:"get",
cache: "false",
url: "ajaxget.asp教程",
data:"url="+url,
datatype: "html",
error: function(){$("#weather").html("读取失败...请刷新重试!");},
success: function(网页特效on){
var t = '('+json+')';
var result = eval(t);
var getinfo="";
getinfo+=result.weatherinfo.date_y+" ";//年月日
getinfo+=result.weatherinfo.date+" ";//农历年月日
getinfo+=result.weatherinfo.week+" ";//星期几
getinfo+="<br />";//换行
getinfo+=result.weatherinfo.city;//获取城市名称
getinfo+=" <img src="http://m.weather.com.cn/img/c"+result.weatherinfo.img1+".gif"/> "//天气图片1
getinfo+="<img src="http://m.weather.com.cn/img/c"+result.weatherinfo.img2+".gif"/> ";//天气图片2
getinfo+=result.weatherinfo.weather1+" ";//天气情况
getinfo+=result.weatherinfo.temp1;//温度
$.cookie(cookie_info,getinfo, { path: '/', expires: date });
$("#weather").html(getinfo);
}
});
}
<div id="weather" style="font-size:12px;"></div>
相关文章推荐
- Json获取中国天气网天气的代码
- asp下以Json获取中国天气网天气的代码
- asp下以Json获取中国天气网天气的代码
- asp下以Json获取中国天气网天气的代码
- 中国天气网城市代码(JSON)获取实现(二)
- 中国天气网城市代码(JSON)获取实现(一)
- PHP Ajax JavaScript Json获取天气信息实现代码
- PHP Ajax JavaScript Json获取天气信息实现代码
- 改:Json获取中国天气网天气。
- Json获取中国天气网天气。
- 使用天气预报api(中国天气网)获取城市天气(2)---httpclient和json操作
- JSON之三:获取JSON文本并解释(以google的天气API为例)
- android获取全国城市数据和天气,工程结构及代码十分规范
- 国家气象局免费天气预报接口,城市代码(JSON格式)
- 用python调用中国天气网API获取各大城市的天气信息
- Android导入外部数据库解析json获取天气预报
- vue2.5.2使用http请求获取静态json数据的实例代码
- 一个简单的Android客户端从服务器端获取json数据并解析的实现代码
- Python新手写出漂亮的爬虫代码2——从json获取信息
- java代码解析json对象获取json对象属性值