首页 > 代码库 > asp.net百度SEO主动推送
asp.net百度SEO主动推送
使用asp.net实现百度SEO主动推送代码如下:
1 public static string PostUrl(string[] urls) 2 { 3 try 4 { 5 string formUrl = "http://data.zz.baidu.com/urls?site=www.qizhiku.com&token=yourcode"; 6 7 string formData = http://www.mamicode.com/""; 8 9 foreach (string url in urls) 10 { 11 formData += url + "\n"; 12 } 13 14 byte[] postData =http://www.mamicode.com/ System.Text.Encoding.UTF8.GetBytes(formData); 15 16 // 设置提交的相关参数 17 System.Net.HttpWebRequest request = System.Net.WebRequest.Create(formUrl) as System.Net.HttpWebRequest; 18 System.Text.Encoding myEncoding = System.Text.Encoding.UTF8; 19 request.Method = "POST"; 20 request.KeepAlive = false; 21 request.AllowAutoRedirect = true; 22 request.ContentType = "text/plain"; 23 request.UserAgent = "curl/7.12.1"; 24 request.ContentLength = postData.Length; 25 26 // 提交请求数据 27 System.IO.Stream outputStream = request.GetRequestStream(); 28 outputStream.Write(postData, 0, postData.Length); 29 outputStream.Close(); 30 31 System.Net.HttpWebResponse response; 32 System.IO.Stream responseStream; 33 System.IO.StreamReader reader; 34 string srcString; 35 response = request.GetResponse() as System.Net.HttpWebResponse; 36 responseStream = response.GetResponseStream(); 37 reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.GetEncoding("UTF-8")); 38 srcString = reader.ReadToEnd(); 39 string result = srcString; //返回值赋值 40 reader.Close(); 41 42 return result; 43 } 44 catch(Exception ex) 45 { 46 return ex.Message; 47 }
48 }
使用自动推送之后就可以很方便的推送最新的页面给到百度了。
asp.net百度SEO主动推送
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。