ASP to get the weather in China Weather Network Code _ Thieves/Collection

Source: Internet
Author: User
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.