国产老熟女高潮毛片A片仙踪林,欧美喂奶吃大乳,狠狠爱无码一区二区三区,女神的私人医生动漫免费阅读

新聞建站cms系統(tǒng)、政府cms系統(tǒng)定制開發(fā)

廣州網(wǎng)站建設(shè)公司-閱速公司

asp.net新聞發(fā)布系統(tǒng)、報紙數(shù)字報系統(tǒng)方案
/
http://www.tjsimaide.com/
廣州網(wǎng)站建設(shè)公司
您當(dāng)前位置:首頁>ASP.NET MVC

ASP.NET MVC

百度api如何主動推送sitemap(C#+asp.net)

發(fā)布時間:2020/12/26 12:31:02  作者:Admin  閱讀:510  

廣告:

#region PostBaidu
        /*
        ///http://data.zz.baidu.com/urls?site=www.cha600.com&token=-----

       //說明:此方法適合百度站長,利用此方法可以第一時間將你的原創(chuàng)文章上傳到百度,保護你的著作權(quán),也可以幫你的網(wǎng)站進行引流
        User-Agent: curl/7.12.1
        Host: data.zz.baidu.com
        Content-Type: text/plain
        Content-Length: 83
         //以下是代碼實現(xiàn):
         * */
      ///
        /// 提交文章鏈接到百度
        ///
        ///文章的鏈接
        ///是否為原創(chuàng)
       public static string  PostBaidu(string url,string host,string token, bool IsOriginal,string encodingstr)
        {
            string retString = "";
            string Stie = host;
            string Token = token;
            string urlPage = "http://data.zz.baidu.com/urls?site=" + Stie + "&token=" + Token + "";
            if (IsOriginal)
            {
                urlPage += "&type=original";
            }            
            HttpWebRequest request = null;
            string body = url;
            if (url.Contains(".txt"))
            {
                body = FilePro.ReadText(url, encodingstr);  //如果不是鏈接是文本,直接讀取文本內(nèi)容 url為物理路徑
            }
            Encoding encoding = Encoding.GetEncoding(encodingstr);
            byte[] data = encoding.GetBytes(body);               //這里采用GBK編碼
 
            //設(shè)置提交的參數(shù)         
            request = WebRequest.Create(urlPage) as HttpWebRequest;
            request.Method = "POST";
            request.UserAgent = "curl/7.12.1";
            request.ContentType = "text/plain";
            request.ContentLength = data.Length;
            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(data, 0, data.Length);
                requestStream.Flush();
                requestStream.Close();
            } 
            //測試返回結(jié)果 
            HttpWebResponse response;
            try
            {
                 response = (HttpWebResponse)request.GetResponse();
                
            }
            catch (WebException ex)
            {
                response = (HttpWebResponse)ex.Response;
            }
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            retString = myStreamReader.ReadToEnd();
            return retString;
       }    
      #endregion


//調(diào)用

if (useridfrom == userreg2.Userid)
            {

                //開始主動推送api
                string host = userreg2.Shophost;
                string token = "AJ9l*****";
                string url = userreg2.Shophost + "_sitemap.txt";
                if (url.Contains(".txt"))
                {
                    url = Server.MapPath(Fun.Webdirectory + url);
                }
                bool IsOriginal = false;
                string encodingstr = "GB2312";
                string res = HttpService.PostBaidu(url, host, token, IsOriginal, encodingstr);
                Response.Write(res);
            }
            else
            {
                Response.Write("請登錄店鋪后臺操作!");
            }
            return new EmptyResult();

廣告:

相關(guān)文章
百度api
主動推送
cms新聞系統(tǒng)購買咨詢
掃描關(guān)注 廣州閱速軟件科技有限公司
掃描關(guān)注 廣州閱速科技
主站蜘蛛池模板: 来宾市| 宁津县| 赣州市| 土默特左旗| 南华县| 七台河市| 宕昌县| 开平市| 百色市| 富锦市| 昂仁县| 富民县| 呼玛县| 芦溪县| 苏尼特右旗| 鸡西市| 堆龙德庆县| 古田县| 赤水市| 定兴县| 林州市| 惠水县| 塘沽区| 鹰潭市| 泰和县| 易门县| 五家渠市| 南江县| 娱乐| 苏尼特左旗| 永康市| 汝城县| 云浮市| 陕西省| 临湘市| 类乌齐县| 深州市| 新平| 河津市| 淮安市| 桃园市|