【发布时间】:2023-04-03 14:15:01
【问题描述】:
我在我的 Google 帐户中创建了一个项目。然后使用自定义搜索引擎的 API 密钥和 ID 授权和访问 Google 自定义搜索。 我尝试通过修改示例代码来使用 Python 界面执行搜索。 每次我在此行之后运行代码时都会收到此错误:
service = build("customsearch", "v1",
developerKey="AIxx")
IOError: [Errno 13] 权限被拒绝
我尝试自己创建一个请求,以检查问题出在 Google 还是我。这是我的要求:
https://www.googleapis.com/customsearch/v1?q=olive+garden&cx=00026xx&key=AIxx
它奏效了!所以,现在我完全糊涂了,不知道问题出在哪里。
更奇怪的是,当我尝试使用 Google API 资源管理器执行相同的搜索时,它会返回:Daily Limit Exceeded
【问题讨论】:
-
用超级用户运行,也许对你有帮助。
-
@HasanRamezani 你的意思是使用 sudo 运行 python?
-
由超级用户运行您的脚本。像这样的东西:
sudo python test.py -
@HasanRamezani 成功了。您知道如何在不需要 sudo 的情况下修复它吗?
标签: python google-api google-custom-search api-key google-api-python-client