/// <summary> /// 获取所有超链接(a)匹配项,其中组1为链接地址值,组2为链接显示内容 /// </summary> public static IEnumerable <Match> GetLinks(this 通用扩展.IHtmlString s) { return(s.Value.RegexMatches(@"<a.+?href=[""'](.+?)[""'].*?>(.+?)</\s*?a>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Cast <Match>()); }
/// <summary> /// 获取所有图像(img)匹配项,其中组1为图像地址值 /// </summary> public static IEnumerable <Match> GetImages(this 通用扩展.IHtmlString s) { return(s.Value.RegexMatches(@"<img.+?src=[""'](.+?)[""'].*?>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Cast <Match>()); }
/// <summary> /// 获取标题 /// </summary> public static string GetTitle(this 通用扩展.IHtmlString s) { return(s.Value.RegexMatch(@"<title.*?>(.+?)</title>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim()); }