版权属于:瞌学家 所有,转载请注明出处 本文链接:https://www.songonline.top/archives/192/ 友情提示: 如果文章部分链接出现404,请留言或者联系博主修复。
【必应】Bing自动提交收录python脚本
一、获取apikey
二、推送脚本
import requests
import re
def get_urls(sitemap):
response = requests.get(url=sitemap)
urls = re.findall('<loc>(.*?)</loc>', response.text)
return urls
def submit_bing(site_url: str, url_list: list, api_key: str):
try:
response = requests.post(url=f"https://ssl.bing.com//webmaster/api.svc/json/SubmitUrlbatch?apikey={api_key}",
json={
'siteUrl': site_url,
'urlList': url_list
},
headers={
'Host': 'ssl.bing.com',
'Content-Type': 'application/json; charset=utf-8',
})
print(response.status_code)
except Exception as e:
print('e')
finally:
if response.status_code == 200 and response.json().get('d') is None:
print('推送成功:')
for i in url_list:
print(i)
else:
print('推送失败:推送配额不足,前往https://www.bing.com/webmasters/submiturl查看配额')
if __name__ == '__main__':
apiKey = '41b××××××××××××××××××××××ebf'
siteUrl = 'https://www.songonline.top/'
urlList = get_urls('https://www.songonline.top/sitemap.xml')
submit_bing(site_url=siteUrl, url_list=urlList, api_key=apiKey)
推送结果
三、提高今天的剩余配额
一开始的时候配额只有10 ,我现在每天有1000 配额,对个人博客完全够用。
提高配额方法:
点击了解更多
会看到NOTE:
If you think the quota provided is not enough, you can proactively request quota increment by creating a support ticket. We will review your request and update your quota accordingly.
意思是:
如果您认为提供的配额不够,您可以通过创建支持工单主动请求配额增加。我们将审核您的请求并相应地更新您的配额。 所以点击链接去请求吧
推送失败
- 检查自己每日推送配额是否足够
- 检查站点地图、apikey、网站是否填写正确
|