05
2017
11

用python给百度站长平台主动推送收录链接

import requests
import time
def main():
    fp = open('/Users/urls.txt')
    urls = []
    headers = {
        'Content-Type': 'text/plain'
    }
    url='http://data.zz.baidu.com/urls?site=你的域名&token=你在百度站长平台的token'
    for line in fp.readlines():
        urls.append(line)
        if len(urls) == 2000:
            data = '\n'.join(urls)
            r = requests.post(url, headers=headers, data=data)
            print(r.json())
            urls.clear()
            time.sleep(1)
    if len(urls)>0:
        data = '\n'.join(urls)
        r = requests.post(url, headers=headers, data=data)
        print(r.json())
    fp.close()

if __name__=='__main__':
    main()


上一篇:sphinx 配置文件全解析 参数说明 下一篇:国内所有ip地址网段