您现在的位置是:网站首页> 编程资料编程资料
asp.net实现根据城市获取天气预报的方法_实用技巧_
2023-05-24
297人已围观
简介 asp.net实现根据城市获取天气预报的方法_实用技巧_
本文实例讲述了asp.net实现根据城市获取天气预报的方法。分享给大家供大家参考,具体如下:
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 转换成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程序设计有所帮助。
您可能感兴趣的文章:
相关内容
- asp.net实现将Excel中多个sheet数据导入到SQLSERVER中的方法_实用技巧_
- asp.net实现从Txt文件读取数据到数据视图的方法_实用技巧_
- asp.net实现数据从DataTable导入到Excel文件并创建表的方法_实用技巧_
- asp.net使用DataTable构造Json字符串的方法_实用技巧_
- asp.net基于Web Service实现远程上传图片的方法_实用技巧_
- asp.net简单实现单点登录(SSO)的方法_实用技巧_
- asp.net实现获取客户端详细信息_实用技巧_
- ASP.NET通用权限验证的实现代码思路_实用技巧_
- asp.net实现微信公众账号接口开发教程_实用技巧_
- ASP.NET微信开发(接口指南)_实用技巧_
