看到正则就犯晕了HTML格式如下<a href="mailto:[email protected]">[email protected]</a>
WebClient wClient = new WebClient();
byte[] meWeb = wClient.DownloadData("http://xxx");
string meHtml = System.Text.Encoding.Default.GetString(meWeb);
string meEmail = ""; Regex reg = new Regex(@"(?is)<a[^>]*?href=(['""]?)(?<href>[^'""\s>]+)\1[^>]*>");
MatchCollection mc = reg.Matches(meHtml);
foreach (Match m in mc)
{
TextBox2.Text += m.Groups["href"].Value + "\n";
}
我这个是把所有的href整出来了如何只提取这个a标签的email地址呢。 求教了
WebClient wClient = new WebClient();
byte[] meWeb = wClient.DownloadData("http://xxx");
string meHtml = System.Text.Encoding.Default.GetString(meWeb);
string meEmail = ""; Regex reg = new Regex(@"(?is)<a[^>]*?href=(['""]?)(?<href>[^'""\s>]+)\1[^>]*>");
MatchCollection mc = reg.Matches(meHtml);
foreach (Match m in mc)
{
TextBox2.Text += m.Groups["href"].Value + "\n";
}
我这个是把所有的href整出来了如何只提取这个a标签的email地址呢。 求教了
byte[] meWeb = wClient.DownloadData("http://xxx");
string meHtml = System.Text.Encoding.Default.GetString(meWeb);
string meEmail = ""; Regex reg = new Regex(@"(?is)<a[^>]*?href=(['""]?)mailto:(?<email>[^'""]*?)\1[^>]*>");
MatchCollection mc = reg.Matches(meHtml);
foreach (Match m in mc)
{
TextBox2.Text += m.Groups["email"].Value + "\n";
}