asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法
來源:懂視網(wǎng)
責(zé)編:小采
時間:2020-11-27 22:37:55
asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法
asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法:本文實例講述了asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法。分享給大家供大家參考,具體如下: public void GetWetheaerByCity(string cityName) { string city = cityName; string mycity = HttpUtility.UrlEncode(c
導(dǎo)讀asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法:本文實例講述了asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法。分享給大家供大家參考,具體如下: public void GetWetheaerByCity(string cityName) { string city = cityName; string mycity = HttpUtility.UrlEncode(c
本文實例講述了asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法。分享給大家供大家參考,具體如下:
public void GetWetheaerByCity(string cityName) {
string city = cityName;
string mycity = HttpUtility.UrlEncode(city, System.Text.Encoding.GetEncoding("GB2312"));
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://www.sina.com/index.php?city=" + cityName);
//HttpWebRequest 對象 獲取GetResponse 轉(zhuǎn)換成HttpWebResponse
System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
//通過HttpWebResponse response.GetResponseStream()獲取
輸出流
Stream str = response.GetResponseStream();
StreamReader reader = new StreamReader(str, System.Text.Encoding.GetEncoding("GB2312"));
string weathhtml = reader.ReadToEnd();
str.Close();
reader.Close();
}
希望本文所述對大家asp.net程序設(shè)計有所幫助。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法
asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法:本文實例講述了asp.net實現(xiàn)根據(jù)城市獲取天氣預(yù)報的方法。分享給大家供大家參考,具體如下: public void GetWetheaerByCity(string cityName) { string city = cityName; string mycity = HttpUtility.UrlEncode(c