using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace 获取页面所有邮箱地址
{
class Program
{
static void Main(string[] args)
{
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
//下载页面中的所有字符串
string html = wc.DownloadString("");
//获取所有的邮箱
MatchCollection matches = Regex.Matches(html, "([0-9a-zA-Z_.-]+)@([0-9a-zA-Z]+([.][a-zA-Z]+){1,2})");
//是Match类型
foreach(Match item in matches)
{
//判断一下是否成功
if(item.Success)
{
//显示邮箱的账号和域名
Console.WriteLine(item.Groups[1].Value + "---" + item.Groups[2].Value);
}
}
Console.WriteLine(matches.Count);
Console.ReadKey();
}
}
}