Asp.net is used to obtain weather forecasts based on cities,

Source: Internet
Author: User

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?

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.