C # Implementation of Baidu Webmaster Tools link Active Submission function

Source: Internet
Author: User

Baidu Webmaster tools to provide links to push the function, so that the majority of the webmaster more convenient to push their own links to Baidu, increase the inclusion of opportunities and shorten the collection time (of course, Baidu also said that you submitted a link, I do not necessarily included!). )


Baidu provides a number of ways, there are active push, automatic push, Sitemap push and so on. Today we have to say is the initiative to push, from the literal meaning can be clearly seen, the initiative to push, that is, the webmaster to push the link to Baidu. So how does it work? In fact, the principle is very simple, is to push the link post to Baidu designated address to be able to.


below we use C # to implement, the source code is as follows:

Push Link to Baidu Private string posturl (String data) {    try     {string url =  "Http://data.zz.baidu.com/urls?site= Here Change your website domain name &token= here to your own token"; httpwebrequest request =  (HttpWebRequest) httpwebrequest.create (URL); request. method =  "POST"; request. useragent =  "curl/7.12.1"; request. contenttype =  "Text/plain"; request. Contentlength = data. length;//converts the argument to a byte array and writes it to the request in Stream stream = request. GetRequestStream (); byte[] byt = encoding.utf8.getbytes (data); stream. Write (Byt, 0, byt. Length); stream. Close ();//Get response httpwebresponse response = request. GetResponse ()  as HttpWebResponse;if  (response. Statuscode == httpstatuscode.ok) {   //Note that this is to be changed according to the website encoding format    using  ( Streamreader sr = new streamreader (response. GetResponseStream (),  encoding.getencoding ("UTF-8 "))    {//return the request result STRING RESULT = SR. ReadToEnd (); response. Close (); return result;   }}else{   //Connection Failed    return null ;}     }    catch    {return null;     }}

Calling code:

PostURL ("You want to push the link address, such as http://www.itc8.com/detail/2016/0114/6475.html");

A successful push returns a JSON string in the following format

{"Remain:xxx", "Success": 0}, where xxx indicates how many links you can push again today. General new website words can only push 500 per day, note, push the repeated link is also to reduce the number of bars.


After the push is complete, you can see the push situation the day before.


Original address: HTTP://WWW.JIANFANGKK.COM/OTHER/201601/2

C # Implementation of Baidu Webmaster Tools link Active Submission function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.