public static string GetMetaContentValue(string pagesource, string metaname)
{
if (pagesource.Length == 0 || metaname.Length == 0)
return "";
pagesource = pagesource.Replace("data-meta-updatable", "");
pagesource = pagesource.Replace(@"data-ephemeral=""true""", "");
pagesource = Regex.Replace(pagesource, @"< *meta id *= *""[^""]+""", "<meta ");
pagesource = Regex.Replace(pagesource, @"\bng\-attr\-content *= *""{{[^""]+}}""", "");
Regex metaContent = new Regex(@"< *meta +(?:xmlns=""http://www\.w3\.org/1999/xhtml"" +)?(?:name|property|itemprop) *= *(?:""|')" + Regex.Escape(metaname) + @"(?:""|')[^<>/]+content *= *(?:""|')([^""<>]+?)(?:""|') */? *>", RegexOptions.IgnoreCase);
Regex metaContent2 = new Regex(@"< *meta +(?:xmlns=""http://www\.w3\.org/1999/xhtml"" +)?[^<>/]*content *= *(?:""|')([^""<>]+?)(?:""|') *(?:name|property) *= *(?:""|')" + Regex.Escape(metaname) + @"(?:""|') */? *>", RegexOptions.IgnoreCase);
if (metaContent.IsMatch(pagesource))
return metaContent.Match(pagesource).Groups[1].Value.Trim();
return metaContent2.Match(pagesource).Groups[1].Value.Trim();
}