Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 使用Google Drive API从共享链接下载整个Google Drive文件夹_Python 2.7_Google Drive Api_Google Api Python Client - Fatal编程技术网

Python 2.7 使用Google Drive API从共享链接下载整个Google Drive文件夹

Python 2.7 使用Google Drive API从共享链接下载整个Google Drive文件夹,python-2.7,google-drive-api,google-api-python-client,Python 2.7,Google Drive Api,Google Api Python Client,我有一个谷歌驱动器文件夹的共享链接。我想使用驱动器API下载整个文件夹。我目前的做法是获取“children”列表,然后将所有“children”实例下载到文件夹中。问题是,对于每个“children”实例下载,都会向googleapis发送一个请求。因此,如果有1000个文件,将发送1000个请求。我有一个包含超过1000万个小文件的文件夹,谷歌将每天的请求数量限制在1000万个。 我想知道是否有办法(驱动api中的任何函数)立即下载整个文件夹? 这是我的密码: storage = Stora

我有一个谷歌驱动器文件夹的共享链接。我想使用驱动器API下载整个文件夹。我目前的做法是获取“children”列表,然后将所有“children”实例下载到文件夹中。问题是,对于每个“children”实例下载,都会向googleapis发送一个请求。因此,如果有1000个文件,将发送1000个请求。我有一个包含超过1000万个小文件的文件夹,谷歌将每天的请求数量限制在1000万个。 我想知道是否有办法(驱动api中的任何函数)立即下载整个文件夹? 这是我的密码:

storage = Storage(CredentialsModel, 'id', task_request.user, 'credential')
credential = storage.get()
http = httplib2.Http()
http = credential.authorize(http)
service = build('drive', 'v2', http=http)

file_list = []
children = service.children().list(folderId=folder_id, q=q, **param).execute()
for child in children.get('items', []):
    file_list.append(child['id'])

for k in range(len(file_list)):
    curr_file = service.files().get(fileId=file_list[k]).execute()
    download_url = curr_file.get('downloadUrl')
    if download_url:
        resp, content = service._http.request(download_url)

    if resp.status == 200:
        title = drive_file.get('title')
        path = title
        file = open(path, 'wb')
        file.write(content)

据我所知不是这样,但这似乎是一个合理的增强要求。你也可以直接ping谷歌,看看是否可以提高你的应用程序的限制。根据文件的大小,您可能还需要重新考虑您的体系结构。将文件作为数据存储在电子表格或fusion表中可能更合适。@pinoyyid这些文件是图像文件!这里有一个可能奏效的技巧:驱动器图像文件可以作为google+相册查看,而g+可以作为zip下载整个相册。你是它的手册(没有api)和IX不知道如何使驱动器中的图片是在加(另一种方式周围确实发生)Ok!根据Zig的建议,您还可以看看PicasaAPI,它可能提供类似的功能(猜测)