Skip to content

Instantly share code, notes, and snippets.

@mchoiruln
Last active March 29, 2020 04:08
Show Gist options
  • Save mchoiruln/f094a595f8a9ac33e0a105227b07d4b8 to your computer and use it in GitHub Desktop.
Save mchoiruln/f094a595f8a9ac33e0a105227b07d4b8 to your computer and use it in GitHub Desktop.
Download Google Drive Files With WGET or CURL
cd ~
export fileid=1sNhrr2u6n48vb5xuOe8P9pTayojQoOc_
export filename=file
## WGET ##
wget --save-cookies cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid -O- \
| sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt
wget --load-cookies cookies.txt -O $filename \
'https://docs.google.com/uc?export=download&id='$fileid'&confirm='$(cat confirm.txt)
## CURL ##
curl -L -c cookies.txt 'https://docs.google.com/uc?export=download&id='$fileid \
| sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1/p' > confirm.txt
curl -L -b cookies.txt -o $filename \
'https://docs.google.com/uc?export=download&id='$fileid'&confirm='$(cat confirm.txt)
rm -f confirm.txt cookies.txt
cd ~
export fileid=1yXsJq7TTMgUVXbOnCalyupESFN-tm2nc
export filename=file
## WGET ##
wget -O $filename 'https://docs.google.com/uc?export=download&id='$fileid
## CURL ##
curl -L -o $filename 'https://docs.google.com/uc?export=download&id='$fileid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment