62,269
社区成员
发帖
与我相关
我的任务
分享
string str =string.Empty;
WebRequest Wrq = WebRequest.Create("http://www.baidu.com");
WebResponse Wrs = Wrq.GetResponse();
Stream strm = Wrs.GetResponseStream();
StreamReader sr = new StreamReader(strm, System.Text.Encoding.GetEncoding("UTF-8"));
string allstrm;
allstrm = sr.ReadToEnd();
string strPattern = @"正则表达式";
MatchCollection Matches = Regex.Matches(allstrm, strPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
foreach (Match NextMatch in Matches)
{
str = NextMatch.Groups[0].Value.ToString().Trim();
}