问题描述
我正在使用此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 (将#修改为@)