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/"));
}
比较简单,没有做什么处理,只是替换了图片的地址。
本文提供了一个使用C#进行简单的HTTP请求,从网页获取HTML内容并替换图片地址的示例代码。代码中包括了创建HTTP请求、获取响应、读取HTML内容以及替换图片URL的基本步骤。
384

被折叠的 条评论
为什么被折叠?



