Baidu a bit, find some other people's method improved a bit.
Get weather URL: http://www.weather.com.cn/html/weather/101210701.shtml This is Wenzhou, of course, the other cities to search their own, change the ID.
Since it is written to record cookies for the day, all needs to be browsed under the site.
JS Code:
Copy Code code as follows:
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 * * 1000) + (1 * 1 * mins * 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 ("read failed ... Please refresh and try again! ");
Success:function (JSON) {
var t = ' (' +json+ ') ';
var result = eval (t);
var getinfo= "";
Getinfo+=result.weatherinfo.date_y+ "";/month Day
Getinfo+=result.weatherinfo.date+ "";//lunar Calendar Month Day
getinfo+=result.weatherinfo.week+ "";//days of the week
getinfo+= "<br/>";//Line change
getinfo+=result.weatherinfo.city;//Get city Name
getinfo+= "getinfo+= "getinfo+=result.weatherinfo.weather1+ "";//weather conditions
getinfo+=result.weatherinfo.temp1;//temperature
$.cookie (Cookie_info,getinfo, {path: '/', expires:date});
$ ("#weather"). HTML (Getinfo);
}
});
}
HTML code:
Copy Code code as follows:
<div id= "Weather" style= "font-size:12px;" ></div>
This is used on the network common ASP crawl, of course, can also be replaced by. NET crawl or other. Attached demo.