安装gdown
pip install gdown
获取Google drive文件(不能是文件夹)的ID
复制到的链接大概长下面这个样子,其中加粗的部分就是文件的ID
/12LhpGHvGu4wIgXrONspNKqfGFpTfr0-p/view?usp=drive_link
在Python中运行(注意下面的url
和上面的不太一样)
>>> import gdown
>>> url = '=12LhpGHvGu4wIgXrONspNKqfGFpTfr0-p'
>>> output = ''
>>> gdown.download(url, output, quiet=False)
这个方法对中小型文件可行,但对过大的文件(以上图中40GB的文件为例,文件ID
是1CDuzEbjK1hPbMItoJwrLIMgK25FSRM6_
),会报下面的错
Access denied with the following error:Too many users have viewed or downloaded this file recently. Pleasetry accessing the file again later. If the file you are trying toaccess is particularly large or is shared with many people, it maytake up to 24 hours to be able to view or download the file. If youstill can't access a file after 24 hours, contact your domainadministrator.You may still be able to access the file from the browser:=1CDuzEbjK1hPbMItoJwrLIMgK25FSRM6_
这时,就需要使用Token和命令行下载(以下内容参考自stackoverflow)。
进入 /
找到这一条并点击,然后点下面的 Authorize APIs
再点击出现的Exchange authorization code for tokens
复制生成的 Access Toekn
在终端运行(注意,下面的ACCESS_TOKEN
要换成刚才复制的,FILE_ID
改成要下载的文件ID
,FILE_NAME
改成要保存的文件名)
curl -H "Authorization: Bearer ACCESS_TOKEN" =media -o FILE_NAME
然后就开始漫长的传输了。
本文发布于:2024-02-04 06:04:49,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170700630252930.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |