参考:
<40M 文件 且是 公开分享:
用wget:
https://lccurious.github.io/2021/05/15/Download-from-Google-Drive/
<10G 且是 公开分享:
curl:
https://github.com/JinhangZhu/yolov3/blob/custom/data/get_coco2014.sh
# cd scratch place
cd scratch/
# Download zip dataset from Google Drive
filename='OfficeHomeDataset_10072016.zip'
fileid='0B81rNlvomiwed0V1YUxQdC1uOTg'
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
rm ./cookie
# Unzip
#unzip -q ${filename}
#rm ${filename}
# cd out
cd
>10G 或者是 私密分享:
上面的方法会出现找不到文件的情况,用Google的官方API和认证token可以解决:
https://www.pianshen.com/article/8221279796/
或者查看英文原版问题答案:
Get the file ID:
Go to your Google Drive in your browser.
Right-click (or control-click) the file you want to download and click “Get shareable link”. The link looks like this: https://drive.google.com/open?id=XXXXX. Make note of the file ID “XXXXX”; you will be needing it below.
Get an OAuth token:
Go to OAuth 2.0 Playground
In the “Select the Scope” box, scroll down, expand “Drive API v3”, and select https://www.googleapis.com/auth/drive.readonly
Click “Authorize APIs” and then “Exchange authorization code for tokens”. Copy the “Access token”; you will be needing it below.
Download the file from the command line:
curl -H “Authorization: Bearer YYYYY” https://www.googleapis.com/drive/v3/files/XXXXX?alt=media -o ZZZZZ