【发布时间】:2019-11-21 16:37:47
【问题描述】:
我正在尝试使用 python 使用谷歌索引 API,但不断收到以下错误:
'TypeError: Can't concat bytes to str'
这是我目前编写的代码:
SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
JSON_KEY_FILE = "json_key.json"
credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)
http = credentials.authorize(httplib2.Http())
content = {"url" : "https://careers.google.com/jobs/google/technical-writer",
"type" : "URL_UPDATED"
}
response, content = http.request(ENDPOINT, method="POST", body=content)
有谁知道我为什么会收到这个错误以及如何解决它?
【问题讨论】:
标签: python google-api urllib2