Member-only story
Gdown下載Google雲端硬碟資料夾中的檔案,遇到24小時內太多人進行下載的限制
1 min readMar 17, 2023
pip install gdown #安裝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.
解決方案:
1. 進入 https://developers.google.com/oauthplayground/
在Step 1 Select & authorize APIs貼上https://www.googleapis.com/auth/drive.readonly,點擊Authorize APIs
2. 至Step 2 Exchange authorization code for tokens,複製Access token
3. 在Terminal執行
curl -H "Authorization: Bearer XXX-YOUR-ACCESS-TOKEN-XXX" https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media -o FILENAME.zip
# 其中XXX-YOUR-ACCESS-TOKEN-XXX為自己的Access token
# FILE_ID為檔案ID
# FILENAME.zip為檔名,需依照自己欲下載的檔案名稱進行調整
2024/1/25更新:
如果有大量檔案要下載,但遇到24小時上限的問題,可以怎麼做?
- 蒐集每個想下載檔案的下載連結
- 使用正則表達式搭配pattern搜尋FILEID
- 將FILEID與down_url配對
- 使用curl進行下載