及时发现:可以缩短百度爬虫发现您站点新链接的时间,使新发布的页面可以在第一时间被百度收录
保护原创:对于网站的最新原创内容,使用主动推送功能可以快速通知到百度,使内容可以在转发之前被百度发现
需要网站制作数据推送接口,进入主动推送工具后,会看到接口调用地址的token,token是由16个英文数字组合的字符串!
请前往站长平台查看您的推送效果!一般24小时左右就能查看到百度站长平台的主动实时推送记录
如果自己喜欢动手的话,可以参考以下代码,来自己写
python2.7版本推送代码
#! /usr/bin/env python
#coding=utf-8
#百度推送 by tools.bugscaner.com
import httplib
data = open("sitemap.txt","r").read()
allurls = data.split("\n")
nbs = len(allurls)
if nbs/2000*2000 != nbs:
all = nbs/2000 + 1
else:
all = nbs/2000
for x in range(1,all+1):
urlinfos ="\n".join(allurls[(x-1)*2000:x*2000])
headers = {"Content-Type":"application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection("data.zz.baidu.com")
try:
conn.request("POST","/urls?site=tools.bugscaner.com&token=QesN4asTDZH1bjfq",urlinfos,headers)
httpres = conn.getresponse()
html = httpres.read()
print html
except Exception,e:
print e
php版本推送代码
$urls = array(
'http://www.example.com/1.html',
'http://www.example.com/2.html',
);
$api = 'http://data.zz.baidu.com/urls
site=tools.bugscaner.com&token=QesN4asTDZH1bjfq';
$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推送示例
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=www.xxx.com&token=eTk7ychrWZP1pDQD')
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
如果以上环境您都没有安装...
步骤1:安装火狐浏览器 步骤2:然后安装附件 hackbar 步骤3:post提交您的网址即可! 简单吧,如果不想折腾,就直接用这个页面提交吧! 其实我也是为了方便自己提交写的!O(∩_∩)O
以免有人恶意请求,影响大家的使用,一分钟只能推送30次,一天只能推送100次
一次推送2000条网址,100次大概可以推送20万条网址,也就是说明天您可以使用本页面推送20万网址,百度每天给的额度是500万