网站地图Sitemap站长推送工具Python版支持百度站长、神马站长、Bing站长自动化SiteMap地图链接提交,免去手动Api提交网址。
Python代码
- import requests
- import re
- def bing(urls):
- global bing_number
- headers = {
- 'Content-Type': 'application/json; charset=utf-8',
- 'Host': 'ssl.bing.com',
- }
- api = 'https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=站长Key'
- print('Bing站长推送中...')
- for page in urls:
- json = {
- 'siteUrl': 'https://域名',
- 'url': page
- }
- response = requests.post(api, json=json, headers=headers).json()
- if 'd' in response.keys():
- bing_number = bing_number + 1
- else:
- break
- def baidu(urls):
- global baidu_number
- headers = {
- 'User-Agent': 'curl/7.12.1',
- 'Host': 'data.zz.baidu.com',
- 'Content-Type': 'text/plain',
- 'Content-Length': '83'
- }
- api = '百度站长API'
- print('百度站长推送中...')
- for page in urls:
- response = requests.post(api, data=page, headers=headers).json()
- if 'success' in response.keys():
- baidu_number = baidu_number + 1
- else:
- break
- def shenma(urls):
- global shenma_number
- headers = {
- 'User-Agent': 'curl/7.12.1',
- 'Host': 'data.zhanzhang.sm.cn',
- 'Content-Type': 'text/plain',
- 'Content-Length': '83'
- }
- api = '神马API'
- print('神马站长推送中...')
- for page in urls:
- try:
- response = requests.post(api, data=page, headers=headers).json()
- if response['returnCode'] == 200:
- shenma_number = shenma_number + 1
- else:
- break
- except:
- break
- if __name__ == '__main__':
- bing_number = 0
- baidu_number = 0
- shenma_number = 0
- url = 'Sitemap.xml文件地址'
- response_html = requests.get(url)
- html = response_html.text
- urls = re.findall('<loc>(.*?)</loc>', html)
- bing(urls)
- baidu(urls)
- shenma(urls)
- print('Bing站长共计推送:%s\n百度站长共计推送:%s\n神马站长共计推送:%s' % (bing_number, baidu_number, shenma_number))
API获取方式
百度站长:https://ziyuan.baidu.com/dashboard/index
神马站长:https://zhanzhang.sm.cn/open/detialPage
Bing站长:API申请方式:必应Webmaster Tools API创建
使用方法
Python文件:https://drive.manwuji.com/2021-11/seo.py
在宝塔面板中定时任务处设置定时任务,具体配置方法参考:PT签到助手Python版进行配置。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。