private static System.Text.Encoding getEncoding(string url) { string hTMLContent = HttpCollects.GetHTMLContent(url, System.Text.Encoding.UTF8, "charset\\b\\s*=\\s*(?<charset>[a-zA-Z\\d|-]*)"); Regex regex = new Regex("charset\\b\\s*=\\s*(?<charset>[a-zA-Z\\d|-]*)"); System.Text.Encoding encoding = System.Text.Encoding.UTF8; if (regex.IsMatch(hTMLContent)) { foreach (Match match in regex.Matches(hTMLContent)) { try { if (!string.IsNullOrEmpty(match.Groups["charset"].Value)) { encoding = System.Text.Encoding.GetEncoding(match.Groups["charset"].Value); if (encoding != null) { break; } } } catch { } } } return(encoding); }
public static string GetHTMLContent(string url) { return(HttpCollects.GetHTMLContent(url, null, null)); }
public static string GetHTMLContent(string url, string endRegexString) { return(HttpCollects.GetHTMLContent(url, null, endRegexString)); }