Using system; using system. data; using system. configuration; using system. collections; using system. web; using system. web. security; using system. web. ui; using system. web. UI. webcontrols; using system. web. UI. webcontrols. webparts; using system. web. UI. htmlcontrols; using system. net; using system. net. security; using system. security. authentication; using system. security. cryptography. x509certificates; using system. text; Using system. io; using system. text. regularexpressions; using system. net. cache; namespace sitemapdemo {/// <summary> /// 2011-06-16 aggregation /// </Summary> Public partial class qqweather: system. web. UI. page {Public String selectcity = "1"; string strurl = "http://weather.qq.com/inc/ss1.htm"; string old = @ "<select id =" "obselect" "onchange =" "getredirect (this. value) ""> "; string old1 = @" <option value = "" 1" "> Hong Kong </option> <option value =" 2 ""> Macao </option> <option value = "17" "> Harbin </option> <option value = "" 28 ""> Urumqi </option> <option value = "" 56 "> Xining </option> <option value =" "57" "> Lanzhou </ option> <option value = "69" "> Hohhot </option> <option value =" "78" "> Yinchuan </option> <option value =" "82" "> Shijiazhuang </option> <option value =" 84 ""> Taiyuan </option> <option value = "" 103 "> Changchun </option> <option value = "" 115 "> Shenyang </option> <option selected value =" "125 ""> Beijing </option> <option value = "127" "> Tianjin </option> <option value =" "140" "> Jinan </option> <Option value = "" 150 ""> Lhasa </option> <option value = "" 166 "> Chengdu </option> <option value =" "179" "> Kunming </option> <option value = "186"> Xi'an </option> <option value = "" 189 "> Zhengzhou </option> <option value =" "211 ""> Wuhan </option> <option value = "212"> Chongqing </option> <option value = "" 218 ""> Changsha </option> <Option value = "" 227 "> Guiyang </option> <option value =" "232" "> Gui Lin </option> <option value = "" 244 "> Nanjing </option> <option value =" "248"> Hefei </option> <option value =" "252" "> Shanghai </option> <option value =" "255"> Hangzhou </option> <option value = "264" "> Nanchang </option> <option value = "" 276 ""> Fuzhou </option> <option value = "" 280 "> Taipei </option> <option value =" "287" "> xiamen </option> <option value = "" 292 "> Guangzhou </option> <option value =" "295"> Nanning </option> <option value =" "296" "> Shenzhen </option> <option value =" "303"> Haikou </o Ption> "; string old2 = @" </SELECT> "; string old3 = @" city "; string old4 = @ " "; string strweather = string. empty; /// <summary> //// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E "> </param> protected void page_load (Object sender, eventargs e) {// servicepointmanager. servercertificatevalidationcallback = new system. net. security. Remotecertificatevalidationcallback (checkvalidationresult); // httpwebrequest Req = (httpwebrequest) webrequest. createdefault (New uri ("http://intranet.lukfook.com.hk/luk_intranet/QQweather.aspx"); // https://intranet.lukfook.com.hk/luk_intranet/QQweather.aspx // req. method = "get"; // httpwebresponse res = (httpwebresponse) req. getresponse (); // selectcity = dropdownlist1.selectedvalue. tostring (); If (! Ispostback) {This. dropdownlist1.datasource = createdatasource (); dropdownlist1.datatextfield = "weathertextfield"; dropdownlist1.datavaluefield = "weathervaluefield"; // bind the data to the control. dropdownlist1.databind (); // set the default selected item, if desired. dropdownlist1.selectedindex = 0; selectcity = @ "1"; strurl = "http://weather.qq.com/inc/ss1.htm"; strweather = gethttpdata (strur L); strweather = strweather. replace (old, ""); strweather = strweather. replace (old1, ""); strweather = strweather. replace (old2, ""); strweather = strweather. replace (old3, ""); strweather = strweather. replace (old4, ""); geovindu. innerhtml = strweather; // gethttpdata (strurl); // response. write (s);}/** <select id = "obselect" onchange = "getredirect (this. value) "> <option value =" 1 "> Hong Kong </option> <option valu E = "2"> Macao </option> <option value = "17"> Harbin </option> <option value = "28"> Urumqi </option> <option value = "56"> Xining </option> <option value = "57"> Lanzhou </option> <option value = "69"> Hohhot </option> <option value = "78"> Yinchuan </option> <option value = "82"> Shijiazhuang </option> <option value = "84"> Taiyuan </option> <option value =" 103 "> Changchun </option> <option value =" 115 "> Shenyang </option> <option selected value =" 125 "> Beijing </option> <option value =" 127 "> Tianjin </option> <OPT Ion value = "140"> Jinan </option> <option value = "150"> Lhasa </option> <option value = "166"> Chengdu </option> <Option value = "179"> Kunming </option> <option value = "186"> Xi'an </option> <option value = "189"> Zhengzhou </option> <option value = "211"> Wuhan </option> <option value = "212"> Chongqing </option> <option value = "218"> Changsha </option> <option value = "227"> Guiyang </option> <option value = "232"> Guilin </option> <option value = "244"> Nanjing </option> <option value =" 248 "> Hefei </option> <Option value = "252"> Shanghai </option> <option value = "255"> Hangzhou </option> <option value = "264"> Nanchang </option> <Option value = "276"> Fuzhou </option> <option value = "280"> Taipei </option> <option value = "287"> Xiamen </option> <option value = "292"> Guangzhou </option> <option value = "295"> Nanning </option> <option value = "296"> Shenzhen </option> <option value = "303"> Haikou </option> */} // <summary> /// </Summary> // <Param name = "sender"> </param> // <Param name = "E "> </Param> protected void button#click (Object sender, eventargs e) {// servicepointmanager. servercertificatevalidationcallback = new system. net. security. remotecertificatevalidationcallback (checkvalidationresult); // httpwebrequest Req = (httpwebrequest) webrequest. createdefault (New uri ("http://intranet.lukfook.com.hk/luk_intranet/QQweather.aspx"); // req. method = "get"; // httpwebresponse res = (HTT Pwebresponse) req. getresponse (); selectcity = dropdownlist1.selectedvalue. tostring (); strurl = "http://weather.qq.com/inc/ss" + selectcity + ". htm "; strweather = gethttpdata (strurl); strweather = strweather. replace (old, ""); strweather = strweather. replace (old1, ""); strweather = strweather. replace (old2, ""); strweather = strweather. replace (old3, ""); strweather = strweather. replace (old4, ""); geovindu. Innerhtml = strweather; // gethttpdata (strurl );} /// <summary> /// <% # selectcity %> /// </Summary> /// <returns> </returns> icollection createdatasource () {datatable dt = new datatable (); DT. columns. add (New datacolumn ("weathertextfield", typeof (string); DT. columns. add (New datacolumn ("weathervaluefield", typeof (string); DT. rows. add (createrow ("Hong Kong", "1", DT); DT. rows. add (createrow ("Australia", "2", DT ); DT. rows. add (createrow ("", "17", DT); DT. rows. add (createrow ("mongoshake", "28", DT); DT. rows. add (createrow ("", "56", DT); DT. rows. add (createrow ("", "57", DT); DT. rows. add (createrow ("Hohhot", "69", DT); DT. rows. add (createrow ("zhucheon", "78", DT); DT. rows. add (createrow ("", "82", DT); DT. rows. add (createrow ("Taiyuan", "84", DT); DT. rows. add (createrow ("Changchun", "103", DT); DT. rows. add (createrow ("zookeeper ", "115", DT); DT. rows. add (createrow ("Beijing", "125", DT); DT. rows. add (createrow ("Tianjin", "127", DT); DT. rows. add (createrow ("Yunnan", "140", DT); DT. rows. add (createrow ("pull progress", "150", DT); DT. rows. add (createrow ("Chengdu", "166", DT); DT. rows. add (createrow ("Kunming", "179", DT); DT. rows. add (createrow ("Xi'an", "186", DT); DT. rows. add (createrow ("", "189", DT); DT. rows. add (createrow (" ow", "211", DT); DT. rows. Add (createrow ("weight", "212", DT); DT. rows. add (createrow ("Changsha", "218", DT); DT. rows. add (createrow ("commandid", "227", DT); DT. rows. add (createrow ("Guilin", "232", DT); DT. rows. add (createrow ("Nanjing", "244", DT); DT. rows. add (createrow ("Hefei", "248", DT); DT. rows. add (createrow ("Shanghai", "252", DT); DT. rows. add (createrow ("Hangzhou", "255", DT); DT. rows. add (createrow ("Nanchang", "264", DT); DT. rows. add (createrow ("Fuzhou "," 276 ", DT); DT. rows. add (createrow ("Bei", "280", DT); DT. rows. add (createrow ("commandid", "287", DT); DT. rows. add (createrow ("", "292", DT); DT. rows. add (createrow ("South Carolina", "295", DT); DT. rows. add (createrow ("Shenzhen", "296", DT); DT. rows. add (createrow ("Haikou", "303", DT); dataview DV = new dataview (DT); Return DV ;} /// <summary> ///// </Summary> /// <Param name = "text"> </param> /// <Param name = "Value "> </ Param> /// <Param name = "DT"> </param> /// <returns> </returns> datarow createrow (string text, string value, datatable DT) {datarow DR = DT. newrow (); Dr [0] = text; Dr [1] = value; return Dr;} public bool checkvalidationresult (Object sender, x509certificate certificate, x509chain chain, sslpolicyerrors errors) {// directly confirm; otherwise, return true cannot be opened ;} /// <summary> ///// </Summary> /// <Param name = "url"> </para M> /// <returns> </returns> Public String gethttpdata (string URL) {try {// 1 WebClient mywebclient = new WebClient (); // WebClient. cachepolicy = new system. net. cache. requestcachepolicy (system. net. cache. requestcachelevel. nocachenostore); stream mystream = mywebclient. openread (URL); webheadercollection myheader = mywebclient. responseheaders; string mycharset = myheader. get ("Content-Type"); match Myma Tch = RegEx. Match (mycharset ,"(? <= (Charset = )). * $ "); streamreader myreader = new streamreader (mystream, encoding. getencoding (mymatch. tostring (); Return myreader. readtoend ();} catch (system. net. sockets. socketexception ex) {return ex. message. tostring () ;}//< summary> //// </Summary> class myclient: WebClient {private bool TF = false; public bool headonly {get {return TF;} set {value = TF;} protected override webrequest getwebrequest (URI address) {webrequest Req = base. getwebrequest (Address); If (headonly & req. method = "get") {req. method = "head" ;}return req ;}}}}