获取页面所有邮箱地址

xiaoxiao2021-02-27  410

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(); } } }
转载请注明原文地址: https://www.6miu.com/read-3995.html

最新回复(0)