/// <summary> /// 添加关键字以及描述 /// </summary> /// <param name="key">关键字</param> /// <param name="des">描述</param> /// <param name="page">Page</param> public static void addMeta(string key, string des, System.Web.UI.Page page) { Literal keywords = new Literal(), description = new Literal(); keywords.Text = "<meta name='Keywords' content='" + key + "' />"; description.Text = "<meta name='Description' content='" + des + "' />"; page.Header.Controls.Add(keywords); page.Header.Controls.Add(description); } /// <summary> /// 读取某网页的关键字或描述 /// </summary> /// <param name="url">链接地址(http://www.baidu.com)</param> /// <param name="Type">所要读取的类别</param> /// <returns></returns> public static string setMeta(string url, string Type) { using (System.Net.WebClient wc = new System.Net.WebClient()) { string html = wc.DownloadString(url); int sp = html.IndexOf("name=" + Type); int se = html.IndexOf("\">", sp); html = html.Substring(sp, se - sp); sp = html.IndexOf("\"") + 1; return html.Substring(sp); } }