Example #1
0
        public static string GetDescription(string html, bool ignoreCas)
        {
            string metaString = HttpCollects.GetMetaString(html, "<meta([\\s]*)name=\"description\"([\\s]*)content=\"", "\"([\\s]*)/?>", ignoreCas);

            if (string.IsNullOrEmpty(metaString))
            {
                metaString = HttpCollects.GetMetaString(html, "<meta([\\s]*)content=\"", "\"([\\s]*)name=\"description\"([\\s]*)/?>", ignoreCas);
            }
            return(metaString);
        }
Example #2
0
        public static string GetTitle(string html, bool ignoreCas)
        {
            string metaString = HttpCollects.GetMetaString(html, "<meta name=\"title\"([\\s]*)content=\"", "\"([\\s]*)/?>", ignoreCas);

            if (string.IsNullOrEmpty(metaString))
            {
                string pattern = "(?<=<title.*>)([\\s\\S]*)(?=</title>)";
                Regex  regex   = new Regex(pattern, RegexOptions.IgnoreCase);
                return(regex.Match(html).Value.Trim());
            }
            return(metaString);
        }