gdown/命令行下载Google Drive文件(大文件也可以)

阅读: 评论:0

gdown/命令行下载Google Drive文件(大文件也可以)

gdown/命令行下载Google Drive文件(大文件也可以)

中小型文件 - 使用gdown

安装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的文件为例,文件ID1CDuzEbjK1hPbMItoJwrLIMgK25FSRM6_),会报下面的错

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改成要下载的文件IDFILE_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小时内删除。

标签:命令行   大文件   文件   gdown   Drive
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23