如何通过curl或wget下载Google Drive网址

问题描述:

有没有办法通过curl或wget下载公开浏览的Google Drive网址?例如,可以执行以下操作:

Is there a way to download a publicly-viewable Google Drive url via curl or wget? For example, being able to do something like:

curl -O myfile.xls https://drive.google.com/uc?export=download&id=1Wb2NfKTQr_dLoFJH0GfM0cx-t4r07IVl

请注意,我正在寻找可公开浏览的文件,无需登录我的Google帐户(或让其他人登录其帐户等)。

Note, I'm looking to do this on a publicly-viewable file without having to sign into my Google account (or have someone else sign into their account, etc.).

如果我有cors头文件:

If helpful, the cors headers I have are:

 "kind": "drive#file",
 "id": "1Wb2NfKTQr_dLoFJH0GfM0cx-t4r07IVl",


您需要使用 -L 开关使curl跟随重定向,并且文件名的正确开关是 -o 。您还应该引用网址:

You need to use the -L switch to make curl follow redirects, and the correct switch for the filename is -o. You should also quote the URL:

 curl -L -o myfile.xls "https://drive.google.com/uc?export=download&id=0B4fk8L6brI_eX1U5Ui1Lb1FpVG8"