您的位置:首页 > 理论基础 > 计算机网络

自己用HttpWebRequest写的一个天气预报小偷

2011-11-30 13:27 381 查看
private void GetWeather(){ HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://weather.news.qq.com/inc/dc189.htm"); request.Method = "Get"; request.ContentType = "application/x-www-form-urlencoded"; WebResponse response = request.GetResponse(); Stream s = response.GetResponseStream(); StreamReader sr = new StreamReader(s,System.Text.Encoding.GetEncoding("GB2312")); string html = sr.ReadToEnd(); s.Close(); sr.Close(); Response.Write(html.Replace("/images/","http://weather.news.qq.com/images/"));}比较简单,没有做什么处理,只是替换了图片的地址。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: