How to submit URLs to Baidu

baidu urls submission banner
Submit URLs to Baidu

Submitting your website to Baidu and letting Baidu start to crawl and index your site is usually the first step of your Baidu SEO campaigns.

The most common ways to do that are as follows:

SEO Shifu’s Baidu URL and sitemap submission tool

It is the quickest way, suitable for those who want a quick and straightforward submission.

Go to SEO Shifu’s Baidu URL submission tool →

Baidu Webmaster Tools

It is the go-to method for most webmasters. The benefit is you can check how the indexation of your website on Baidu changes over time in Baidu Webmaster Tools.

Go to Baidu Webmaster Tools →

Bulk submission using the official Baidu submission APIs

It is the geekier way to submit your URLs to Baidu.

By utilizing Baidu’s official direct submission API, webmasters don’t have to sit there waiting for Baidu to come to your site and find new URLs on your site anymore – now you can directly push new URLs to Baidu, which can potentially make the indexation process much faster.

Isn’t that cool? We have created a quick guide on how to use the APIs below.

Overview

First, you need a Baidu Webmaster Tools account. Baidu assigns each webmaster tools account a unique token, which is part of the request URL for URL submission.

You can find your own access token by going to “链接提交” in your BWT account.

It is a URL like below:

http://data.zz.baidu.com/urls?site=your-website.com&token=your-private-token
Parameters Required Type Notes
site yes string a verified website in Baidu Webmaster Tools
token yes string Your own private token

Quickstart Guide

Curl Example

Let’s assume you have put all the URLs in a file named urls.txt, one URL per line.

curl -H 'Content-Type:text/plain' --data-binary @urls.txt "http://data.zz.baidu.com/urls?site=your-website.com&token=your-private-token"

HTTP Post Method Example

POST /urls?site=your-website.com&token=your-private-token HTTP/1.1
User-Agent: curl/7.12.1 
Host: data.zz.baidu.com 
Content-Type: text/plain 
Content-Length: 83 
http://www.example.com/1.html
http://www.example.com/2.html

PHP Example

$urls = array(
    'http://www.example.com/1.html',
    'http://www.example.com/2.html',
);
$api = 'http://data.zz.baidu.com/urls?site=your-website.com&token=your-private-token';
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;

Ruby Example

require 'net/http'
urls = ['http://www.example.com/1.html', 'http://www.example.com/2.html']
uri = URI.parse('http://data.zz.baidu.com/urls?site=your-website.com&token=your-private-token')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = urls.join("\n")
req.content_type = 'text/plain'
res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
puts res.body

Python Example

import requests

seed_file = open('urls.txt', 'r')
urllist = '\n'.join(seed_file.readlines())

r = requests.post(
"http://data.zz.baidu.com/urls?site=your-website.com&token=your-private-token",
data=urllist,
headers={'content-type':'text/plain'})

print r.text

Responses

Successful submission

{
    "remain":4999998,
    "success":2,
    "not_same_site":[],
    "not_valid":[]
}
String Required Type Notes
success yes int no. of URLs that are successfully submitted
remain yes int no. of URLs left in the daily quota
not_same_site no array not a verified site in your BWT account
not_valid no array invalid URLs submitted

Failed submission

{
    "error":401,
    "message":"token is not valid"
}
String Required Type Notes
error yes int error code, usually a 4xx HTTP status code
message yes string error description

In this post, we have had a quick overview of the 3 most common ways to submit your URLs to Baidu. Got any questions? Leave your comment below or drop us an email today →

Related Articles