Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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 如何使用Google Drive API下载30000张图像?_Python_Amazon S3_Python Requests_Google Drive Api - Fatal编程技术网

Python 如何使用Google Drive API下载30000张图像?

Python 如何使用Google Drive API下载30000张图像?,python,amazon-s3,python-requests,google-drive-api,Python,Amazon S3,Python Requests,Google Drive Api,我需要使用Google Drive API下载30000个图像(我将它们的文件id都保存在本地),这样我就可以将它们上传到AWS S3,但是在向API发送了20-30个图像请求后,我得到了403个错误,这意味着我超过了API配额(每个用户每100秒1000个请求-不确定我是如何超过它的,但这不是重点)。每次请求之间,我的代码都会休眠2秒钟,但我仍然会收到此错误。我需要在合理的时间内下载并上载这些文件,有什么建议吗?我不确定您使用哪个库来获取请求。但据我所知,urlopen将为无法处理的文件(如“

我需要使用Google Drive API下载30000个图像(我将它们的
文件id都保存在本地),这样我就可以将它们上传到AWS S3,但是在向API发送了20-30个图像请求后,我得到了403个错误,这意味着我超过了API配额(每个用户每100秒1000个请求-不确定我是如何超过它的,但这不是重点)。每次请求之间,我的代码都会休眠2秒钟,但我仍然会收到此错误。我需要在合理的时间内下载并上载这些文件,有什么建议吗?

我不确定您使用哪个库来获取请求。但据我所知,urlopen将为无法处理的文件(如“403”)引发HTTPError(禁止请求)

参考-

相反,您可以使用-

共享一个小代码示例:-

import urllib.request
url = 'http://example.com/'
response = urllib.request.urlopen(url)
data = response.read()      # a `bytes` object
text = data.decode('utf-8') # a `str`; this step can't be used if data is binary
  • 使用驱动器API下载图像将被视为每个图像的一个请求,因此很容易超过配额限制

  • 幸运的是,有一个变通方法-您可以使用,它允许您一次请求最多下载100幅图像

  • 该文件提供

  • 顺便说一句,您可以在GCP控制台中查看您的

您好,请向我们展示您当前的代码,以及错误的堆栈跟踪、发生位置等。我个人无法回答您的问题,但我相信掌握上述信息将帮助那些试图回答您的人。请查看此处以了解更多信息。
import urllib.request
url = 'http://example.com/'
response = urllib.request.urlopen(url)
data = response.read()      # a `bytes` object
text = data.decode('utf-8') # a `str`; this step can't be used if data is binary