/// <summary> /// 反向链接信息 /// </summary> public static string GetBackLinkInfo(EnumSearchEngine _engine, string Url) { CutRegexInfo model = SeoHelper.GetCutRegexInfo(_engine, Url, false); string Html = HtmlCatch.GetHtml(model.siteUrl, model.encoding); string Result = SeoHelper.GetMetaString(Html, model.regStart, model.regEnd, true); return(HtmlCatch.NoHTML(Result)); }
/// <summary> /// 获取某站点关键字在某搜索引擎的排名 /// </summary> public static string GetKeyWordInfo(EnumSearchEngine _engine, string Url, string KeyWord) { System.Text.RegularExpressions.MatchCollection mc; System.Text.RegularExpressions.MatchCollection mcOther; string Html = ""; string resultText = ""; string searchUrl = ""; Regex reg; Regex regOther; switch (_engine) { case EnumSearchEngine.Baidu: searchUrl = "http://www.baidu.com/s?tn=baiduadv&rn=100&q1="; Html = HtmlCatch.GetHtml(searchUrl + HttpUtility.UrlEncode(KeyWord, System.Text.Encoding.GetEncoding("gb2312")), "gb2312"); // Url = Url.Replace("\\", ""); resultText = SeoHelper.GetMetaString(Html, "<div id=\"wrapper\">", "<font color=\"#008000\">" + Url + "", true); reg = new Regex("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""); regOther = new Regex("<table cellpadding=\"0\" cellspacing=\"0\""); mc = reg.Matches(resultText); mcOther = regOther.Matches(resultText); return((mc.Count + mcOther.Count).ToString()); break; case EnumSearchEngine.Google: Html = HtmlCatch.GetHTMLByUrl("http://www.google.com.hk/search?hl=zh-CN&source=hp&num=100&q=" + HttpUtility.UrlEncode(KeyWord) + "", "Get", "", false, System.Text.Encoding.UTF8); resultText = SeoHelper.GetMetaString(Html, "<title>", "<br><cite>\\S*?" + Url, true); reg = new Regex("<li class=g>"); mc = reg.Matches(resultText); return(mc.Count.ToString()); break; default: break; } return("0"); }