日期:2014-05-17 浏览次数:20809 次
XMLHTTP xmlhttp = new XMLHTTPClass();
xmlhttp.open("get", @"http://sports.sohu.com/s2013/2013zuxiebei/", false, null, null);
xmlhttp.send("");
while (xmlhttp.readyState != 4) Thread.Sleep(1);
string htmldata = Encoding.GetEncoding("GBK").GetString((byte[])xmlhttp.responseBody);
string reg = @"(?is)<a[^>]*?href=(['""])(?<url>[^""]*?/([a-z]
------解决方案--------------------
(\d+?)
------解决方案--------------------
[a-z](\d+?))\.(html
------解决方案--------------------
shtml
------解决方案--------------------
htm))(['""])[^>]*?>(<(img\s[^<>]+
------解决方案--------------------
BR)>)*(?<Content>((?!</a>)[^<>])+)</a>";
Regex Urlreg = new Regex(reg, RegexOptions.Compiled);
MatchCollection matchUrlList = Urlreg.Matches(htmldata);
richTextBox1.Clear();
StringBuilder builder = new StringBuilder();
foreach (Match m in matchUrlList)
{
builder.AppendLine(m.Groups["Content"].Value);
}
richTextBox1.Text = builder.ToString();