复制代码 代码如下:
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
复制代码 代码如下:
WebRequest request = WebRequest.Create("http://目标网址.com/");
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("gb2312"));
//reader.ReadToEnd() 表示取得网页的源码
TextBox1.Text = reader.ReadToEnd();
复制代码 代码如下:
MatchCollection TitleMatchs = Regex.Matches(reader.ReadToEnd(), @"发表评论</a></p></div><divbody"">([/s/S]*?)</div><divshare"">", RegexOptions.IgnoreCase | RegexOptions.Multiline);
foreach (Match NextMatch in TitleMatchs)
{
s += "<br>" + NextMatch.Groups[1].Value;
TextBox1.Text += "/n" + NextMatch.Groups[1].Value;
}
新闻热点
疑难解答
图片精选