This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10268|Reply: 0

[Tips] Use python to implement Baidu's active batch push

[Copy link]
Posted on 10/18/2019 10:55:24 AM | | |
This post was last edited by jimiao on 2019-10-18 10:58

First, you need to install the python development tool (current version 3.7.2)

Because you need to use requests, install the requests package after installing python
#pip3 install requests

Here is the simple python code
#coding:utf8
import requests,time
def pushurls():
        url = "http://data.zz.baidu.com/urls?site=%s&token=%s"%(domain,token) #接口调用地址 Obtained on the webmaster platform

        filecontents = {'file': open('urls.txt', 'r')} #urls.txt the URL file that needs to be pushed, one per line
        print(filecontents)
        r=requests.post(url, files=filecontents)
        baiduresult=u" pushed successfully, and the result was: %s \n" %(r.text)
        print(baiduresult)

if __name__=="__main__":
    domain="www.xxxxx.com" #你的域名
    token="xxxxxxxxxxxxxxx" #你的token (available on the webmaster platform)
    pushurls()


Then edit the URL that needs to be pushed in the urls.txt file, line by line, and execute the python program (F5) in the development tool





Previous:Effective Debugging: 66 effective methods for software and system debugging
Next:Ask for an online class for a junior high school information technology teacher qualification certificate, thank you
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com