Python 成功使用谷歌搜索api
除了正确的Python 成功使用谷歌搜索api,python,google-api,google-api-python-client,Python,Google Api,Google Api Python Client,除了正确的Google公钥之外,我还缺少什么 我收到错误(请参见下面的代码) 在注册以获取 __author__ = '' import pprint from apiclient.discovery import build def main(): ""241d57c296bd9ca73c09a51b422484e879be76cd"" service = build("customsearch", "v1",
Google
公钥之外,我还缺少什么
我收到错误(请参见下面的代码)在注册以获取
__author__ = ''
import pprint
from apiclient.discovery import build
def main():
""241d57c296bd9ca73c09a51b422484e879be76cd""
service = build("customsearch", "v1",
developerKey=google_api_public_key)
res = service.cse().list(
q='lectures').execute()
pprint.pprint(res)
if __name__ == '__main__':
main()
service = build("customsearch", "v1",
developerKey="public_key")
res = service.cse().list(
q='lectures').execute()
#, cx='017576662512468239146:omuauf_lfve').execute()
pprint.pprint(res)
错误:
apiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/customsearch/v1?q=lectures&alt=json&key=241d57c296bd9ca73c09a51b422484e879be76cd returned "Bad Request">
apiclient.errors.HttpError:
看起来您使用了错误的API密钥
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}