文件格式
一般google drive分享的文件链接如下:
https://drive.google.com/file/d/FILE_ID/view?usp=sharing
https://drive.google.com/file/d/xxxxxxxxxxxxxxxxxx/view?usp=sharing
其中我们需要的是FILE_ID
部分
Gdown下载
如果采用Gdown下载(pip install gdown
安装)命令行为
gdown 'https://drive.google.com/uc?id=FILE_ID'
一般不会有问题,但如果是文件太大或者过多人访问,就会出现
Too many users have viewed or downloaded this file recently. Please
try accessing the file again later. If the file you are trying to
access is particularly large or is shared with many people, it may
take up to 24 hours to be able to view or download the file. If you
still can't access a file after 24 hours, contact your domain
administrator.
解决方法
- 进入链接
https://developers.google.com/oauthplayground/
- 在
Select the Scope
栏复制https://www.googleapis.com/auth/drive.readonly
- 点击
Authorize APIs
然后Exchange authorization code for tokens
- 复制
Access token
- 在命令行终端运行
curl -H "Authorization: Bearer Access token" https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media -o FILE_NAME