Baidu has gone through it and found some other methods to improve it.
Get weather URL: Weather.
Because it is written into the cookie record that day weather, all need to browse under the site.
JS Code :
Copy code Code: 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" pai.html (rd_cookie_info );
}
})
function getdata (URL)
{< BR >$. ajax ({
type: "Get",
cache: "false",
URL: "ajaxget. ASP ",
data:" url = "+ URL,
datatype:" html ",
error: function () {$ ("# Weather" ).html ("failed to read... please refresh and try again! ") ;},
success: function (JSON) {
var T = '(' + JSON + ')';
var result = eval (t);
var getinfo = "";
getinfo + = result. weatherinfo. date_y + ""; // year, month, and day
getinfo + = result. weatherinfo. date + ""; // lunar year, month, and day
getinfo + = result. weatherinfo. week + ""; // day of the week
getinfo + = "
"; // line feed
getinfo + = result. weatherinfo. city; // get the city name
getinfo + = "" // weather picture 1
getinfo + = ""; // weather Image 2
getinfo + = result. weatherinfo. weather1 + ""; // weather condition
getinfo + = result. weatherinfo. temp1; // temperature
$. cookie (cookie_info, getinfo, {path: '/', expires: date});
$ ("# Weather" pai.html (getinfo );
}< BR >});
}
HTML code:Copy codeThe Code is as follows: <Div id = "Weather" style = "font-size: 12px;"> </div>
This is a common ASP crawling on the network. Of course, it can also be replaced with. Net crawling or other. Attached demo.