首先注册 「百度搜索资源平台」 创建站点后,得到类似如下的 api 链接:

http://data.zz.baidu.com/urls?site=https://blog.lichenghao.cn&token=xxxx

安装 Python 环境,百度 or lichlaughing的语雀-搭建 python3.x 环境

编写脚本 push-to-baidu.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import feedparser
import requests

# 需要修改
push_url = 'http://data.zz.baidu.com/urls?site=https://blog.lichenghao.cn&token=xxxx'
headers = {
"Host": "data.zz.baidu.com",
"Content-Length": "83"
}
page_list = []
# rss 地址。或者自己整理地址
d = feedparser.parse('https://blog.lichenghao.cn/atom.xml')
for key in d.entries:
page_list.append(key.link)

post_data = '\n'.join(page_list)
response = requests.post(push_url, headers=headers, data=post_data)
print(response.text)

需要在服务器上提前安装依赖

1
2
pip3 install feedparser
pip3 install requests

将脚本上传到服务器的某个位置,配合宝塔使用,更丝滑

正常的执行结果

1
{"remain":2920,"success":20}