Baidu seo

Baidu

the using the System;
 the using the System.Collections.Generic;
 the using the System.Linq;
 the using the System.Text;
 the using the System.Net;
 the using System.Web.Script.Serialization; 

namespace YinLong.Framework.seo 
{ 
    ///  <Summary> 
    /// operation dedicated to the major search engines to help class
     /// /// time: 2015-10-28
     /// /// 
    ///  </ Summary> 
    public  class SeoHelper 
    { 
        ///  <Summary> 
        /// Url sent directly supplied to the Ping Baidu http://ping.baidu.com/ping.html
         ///  </ Summary> 
        /// <param name="url">要发送的url注意带上http://</param>
        /// <returns>成功true 否则为False</returns>
        public static Boolean PingBaidu(string url)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<?xml version=\"1.0\"?>");
                sb.Append("<methodCall>");
                sb.Append("<methodName>weblogUpdates.ping</methodName>");
                sb.Append("<params>");
                sb.Append("<param>");
                sb.Append("<value><string>" + url + "</string></value>");
                sb.Append("</param><param><value><string>" + url + "</string></value>");
                sb.Append("</param>");
                sb.Append("</params>");
                sb.Append("</methodCall>" ); 

                HttpHelperMin HTTP = new new HttpHelperMin (); 
                HttpItemMin Item = new new HttpItemMin () 
                { 
                    the URL = " http://ping.baidu.com/ping/RPC2 " , // the URL required items 
                    Method, = " the POST " , // URL options default to the Get 
                    Referer = " http://ping.baidu.com/ping.html " , // source URL option 
                    postData = sb.ToString (), //Post option data may not need to write the GET 
                    ProtocolVersion = HttpVersion.Version10, 
                }; 
                HttpResultMin Result = http.GetHtml (Item); 

                IF (result.Html.Contains ( " <int> 0 </ int> " )) 
                { 
                    return  to true ; 
                } 
            } 
            the catch {}
             return  to false ; 
        } 

        ///  <Summary> 
        /// the Url provided directly submitted to the original submission Baidu interfaces, need to apply self Taken
         ///  </ Summary> 
        ///  <param name = " curl "> url you want to send the note to bring http://</param>
        /// <param name="token">TzIJxrHBBTH9VdsX默认的Token值</param>
        /// <returns>成功true 否则为False</returns>
        public static OriginalModel OriginalPingBaidu(string curl, string token = "TzIJxrHBBTH9VdsX")
        {
            string url = string.Format("http://data.zz.baidu.com/urls?site={0}&token={1}", new Uri(curl).Host, token);
            HttpHelperMin http = new HttpHelperMin();
            Item HttpItemMin = new new HttpItemMin () 
            { 
                URL = url, // URL required items 
                Method, = " POST " , // URL options default to the Get 
                Referer = curl, // source URL option 
                postData = curl, // Post data available when the option is no need to write GET 
                ProtocolVersion = HttpVersion.Version10, 
                ContentType = " text / Plain " , 
                UserAgent = " curl / 7.12.1 " 
            };
            HttpResultMin result = http.GetHtml(item);

            JavaScriptSerializer jss = new JavaScriptSerializer();
            var model = (OriginalModel)jss.Deserialize<OriginalModel>(result.Html);

            return model;
            //if (result.Html.Contains("\"success\":1"))
            //{
            //    return true;
            //}

            //return false;
        }
        public class OriginalModel
        {
            public int remain { get; set; }
            public int success { get; set; }
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/wangyinlon/p/11819819.html