惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
V
Visual Studio Blog
博客园 - 司徒正美
TaoSecurity Blog
TaoSecurity Blog
博客园 - 聂微东
IT之家
IT之家
博客园_首页
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - Franky
雷峰网
雷峰网
罗磊的独立博客
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
The Cloudflare Blog
T
Tailwind CSS Blog
B
Blog RSS Feed
H
Help Net Security
T
The Blog of Author Tim Ferriss
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
P
Palo Alto Networks Blog
I
Intezer
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
S
Securelist
J
Java Code Geeks
V
V2EX
Y
Y Combinator Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
Forbes - Security
Forbes - Security
Google Online Security Blog
Google Online Security Blog
Help Net Security
Help Net Security
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
Webroot Blog
Webroot Blog
Microsoft Security Blog
Microsoft Security Blog
SecWiki News
SecWiki News
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
N
News and Events Feed by Topic

Oragekk's Blog

OpenSpec 技术分享:用规格驱动 AI 编程 ChatGPT&Codex订阅教程 一个 waline 评论系统bug引发的思考 Jenkins 远程触发构建踩坑记 Git SSH 密钥配置 初识Rust vuepress-plugin-meting2 谷歌发布多平台应用开发神器Project IDX!PaLM 2加持 Vue常见优化手段 Vue2响应式原理解析 Dart 中的并发 Flutter 工作原理 如何利用GitHub Action提交URL到搜索引擎 提交URL到搜索引擎(百度、Bing、Google) GitHub Actions 使用介绍 素材设计 前端-Q&A 浏览器的事件循环 你不知道的 CSS 之包含块 CSS 属性计算过程 Vercel deploy忽略指定分支 评论插件 Waline 之邮件通知配置 公开API 终端究极美化iTerm2+Pure Flutter 基础大集合 关于本站 关于本站 关于我 Markdown 展示 使用n命令管理node版本 幻灯片页 ReactNative State(状态) ReactNative开发环境配置,ES6语法介绍 ReactNative介绍 更优雅强大的终端ZSH 神经网络模型训练 YYCache优秀的缓存设计 WebViewJavascriptBridge NSError WCDB漫谈 优雅的实现TableViewCell单选 初探机器学习框架CoreML 深入理解swift中闭包的捕捉语义 ijkPlayer 集成 iOS 配置https iOS timelineLogistics iOS Cookie的配置及使用 WKWebView拦截URL WKWebView使用及自适应高度 textfield限制输入字符 评论系统从多说迁移到disqus指南 利用Runtime进行快速归档 iOS 10.3 keychain 重大更新 Cell的accessoryType属性标记单元格之后,出现的重用问题 通过UserAgent判断设备 AFNetworking A memory leak 一人一句宋词 OC 中的枚举类型 iOS - Image compression algorithm iOS程序启动原理(下) iOS程序启动原理(上) NSOperatioin TableView性能优化 Runloop Test Three ways to call Update Cocoapods 1.1.1 减小iOS-App或者静态库体积 Jekyll旧站回忆 JavaScript ES6 CommonJS,RequireJS,SeaJS 归纳笔记 Unix/Linux 扫盲笔记
使用Bing API提交网站URL
Oragekk · 2023-03-24 · via Oragekk's Blog

提示

最近在做SEO,因为链接没有做同步,需要清除之前旧站的链接,重新提交,让搜索引擎尽快索引,google search console的已经基本做差不多了

bing最近因为 New Bing 的原因也用的比较多,所以做了一些工作,很方便的是,它可以直接同步GSC的站点数据,不过就只是域数据,URL还是要自己提交

为了尽快索引,只提交sitemap是不够的,还需要调用API手动提交URL

官方示例

bing example
bing example

python代码

python

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

import requests
import xml.etree.ElementTree as ET

# 指定Sitemap的URL
sitemap_url = "https://example.com/sitemap.xml"

# 提取Sitemap中的URL
response = requests.get(sitemap_url)
sitemap_xml = response.content
sitemap_root = ET.fromstring(sitemap_xml)

urls = []
for child in sitemap_root:
    url = child[0].text
    urls.append(url)

# 调用Bing API提交URL
bing_api_key = "your's API Key"
bing_api_url = "https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlBatch?apikey=" + bing_api_key

headers = {"Content-Type": "application/json"}

data = {
    "siteUrl": "https://example.me",
    "urlList": urls
}

response = requests.post(bing_api_url, json=data, headers=headers)
if response.status_code == 200:
    print("URLs submitted successfully!")
else:
    print("Error submitting URLs: ", response.content)

解读

在上面的脚本中,我们首先指定了Sitemap的URL。然后,我们使用Python中的requests库获取Sitemap的内容,并使用Python中的xml.etree.ElementTree库解析Sitemap中的URL。

接下来,我们使用Bing API提交URL。我们首先指定Bing API的密钥和API URL,并设置请求头。然后,我们将Sitemap中提取的URL列表作为数据,将其作为JSON格式发送到Bing API。最后,我们检查响应的状态码,以确保URL已成功提交。

注意:在使用Bing API提交URL之前,需要先注册Bing Webmaster工具,并获取Bing API密钥。还需要将"https://example.com"替换为自己的站点URL。

API密钥生成↘️

  1. 访问Bing Webmaster Tools
  2. 右上角设置
API密钥生成
API密钥生成