【发布时间】:2020-01-08 17:38:26
【问题描述】:
我正在使用 python 从团队拥有的 google 共享驱动器中获取文件。当前的问题是我可以解析所有文件 ID,但我无法使用 pyDrive 下载或读取文件的内容。
首先我生成了一个“驱动器”:
from pydrive.drive import GoogleDrive
from pydrive.auth import GoogleAuth
from pprint import pprint
gauth = GoogleAuth()
# Create local webserver and auto handles authentication.
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
然后我使用文件id来获取内容:
file_id = 'xxx'
file_ = drive.CreateFile({'id': file_id})
content = file_.GetContentString() # <--------------problem line
print(content)
我得到的错误是:
pydrive.files.ApiRequestError: <HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/xxx?alt=json returned "File not found: xxx">
但是,当我转到https://www.googleapis.com/drive/v2/files/xxx?alt=json 时,该文件确实存在,它返回:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
【问题讨论】: