Asp.net is used to obtain weather forecasts based on cities,
This article describes how to obtain weather forecasts based on cities using asp.net. We will share this with you for your reference. The details are as follows:
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); // get GetResponse from HttpWebRequest object and convert it to HttpWebResponse System. net. httpWebResponse response = request. getResponse () as System. net. httpWebResponse; // use HttpWebResponse response. getResponseStream () gets the output Stream str = response. getResponseStream (); StreamReader reader = new StreamReader (str, System. text. encoding. getEncoding ("GB2312"); string weathhtml = reader. readToEnd (); str. close (); reader. close ();}
I hope this article will help you design your asp.net program.
Articles you may be interested in:
- ASP.net (c #) creates a 24-hour Weather Forecast and real-time weather
- C # How to parse Baidu weather data, Rss parse Baidu news, and obtain the City Based on the IP address
- Asp.net to obtain client details
- Asp.net
- ASP. NET
- How does ASP. NET obtain the number of days between two dates?