微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Google Indexing API索引网址

如何解决使用Google Indexing API索引网址

我正在使用此guide创建一个Python程序来为我的网页中的URL编制索引。 我已经测试了指南提供的Python示例

from oauth2client.service_account import ServiceAccountCredentials
import httplib2

ScopES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"

# service_account_file.json is the private key that you created for your service account.
JSON_KEY_FILE = "service_account_file.json"

credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE,scopes=ScopES)

http = credentials.authorize(httplib2.Http())

# Define contents here as a JSON string.
# This example shows a simple update request.
# Other types of requests are described in the next step.

content = """{
  \"url\": \"https://www.generawork.tk/planillas-de-luz-ecuador-2020/",\"type\": \"URL_UPDATED\"
}"""

response,content = http.request(ENDPOINT,method="POST",body=content)

输出是这样的:

b'{\n  "urlNotificationMetadata": {\n    "url": "https://www.generawork.tk/planillas-de-luz-ecuador-2020/",\n    "latestUpdate": {\n      "url": "https://www.generawork.tk/planillas-de-luz-ecuador-2020/",\n      "type": "URL_UPDATED",\n      "notifyTime": "2020-09-03T19:49:05.614934282Z"\n    }\n  }\n}\n'

我一直在等待对该URL进行索引,但是什么也没有发生,这使我认为使用此API只能更新或删除URL

可以使用此API首次为URL编制索引吗? 然后。怎么做?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。