我试图在脚本中从谷歌驱动器下载一个文件,我这样做有点麻烦。我要下载的文件在这里。

我在网上搜了很多,终于下载了其中一个。我得到了文件的uid,较小的文件(1.6MB)下载正常,但较大的文件(3.7GB)总是重定向到一个页面,询问我是否想在不进行病毒扫描的情况下继续下载。谁能帮我跳过那个屏幕?

下面是我如何让第一个文件工作-

curl -L "https://docs.google.com/uc?export=download&id=0Bz-w5tutuZIYeDU0VDRFWG9IVUE" > phlat-1.0.tar.gz

当我对另一个文件进行同样操作时,

curl -L "https://docs.google.com/uc?export=download&id=0Bz-w5tutuZIYY3h5YlMzTjhnbGM" > index4phlat.tar.gz

我得到以下输出-

我注意到在链接的第三行到最后一行,有一个&confirm=JwkK,这是一个随机的4个字符的字符串,但建议有一种方法添加到我的URL确认。我访问的一个链接建议&confirm=no_antivirus,但这不起作用。

我希望这里有人能帮忙!


当前回答

有一个更简单的方法。

从firefox/chrome扩展安装cliget/CURLWGET。

从浏览器下载文件。这将创建一个curl/wget链接,用于记住下载文件时使用的cookie和头文件。使用此命令从任何shell下载

其他回答

警告:此功能已弃用。见下面评论中的警告。


看看这个问题:直接从谷歌驱动器使用谷歌驱动器API下载

基本上,你必须创建一个公共目录,并通过相对引用来访问你的文件

wget https://googledrive.com/host/LARGEPUBLICFOLDERID/index4phlat.tar.gz

或者,您可以使用这个脚本:https://github.com/circulosmeos/gdown.pl

谷歌硬盘也有同样的问题。

下面是我如何使用Links 2解决这个问题。

Open a browser on your PC, navigate to your file in Google Drive. Give your file a public link. Copy the public link to your clipboard (eg right click, Copy link address) Open a Terminal. If you're downloading to another PC/server/machine you should SSH to it as this point Install Links 2 (debian/ubuntu method, use your distro or OS equivalent) sudo apt-get install links2 Paste the link in to your terminal and open it with Links like so: links2 "paste url here" Navigate to the download link within Links using your Arrow Keys and press Enter Choose a filename and it'll download your file

2018年5月

如果你想使用curl从谷歌驱动器下载文件,除了驱动器中的文件id,你还需要谷歌驱动器API的OAuth2 access_token。获取令牌涉及谷歌API框架的几个步骤。谷歌的注册步骤(目前)是免费的。

OAuth2 access_token可能允许所有类型的活动,因此要小心使用它。此外,令牌会在一小段时间后超时(1小时?),但如果有人捕获它,时间还不够短,无法防止滥用。

一旦你有一个access_token和fileid,这将工作:

AUTH="Authorization: Bearer the_access_token_goes_here"
FILEID="fileid_goes_here"
URL=https://www.googleapis.com/drive/v3/files/$FILEID?alt=media
curl --header "$AUTH" $URL >myfile.ext

参见:谷歌驱动器api—REST—下载文件

你只需要使用wget:

 https://drive.google.com/uc?authuser=0&id=[your ID without brackets]&export=download

PD。该文件必须是公共的。

您可以安装“lynx”,在“lynx”的帮助下,您可以轻松下载文件。

yum install lynx

将ID_OF_FILE替换为文件的id

lynx https://drive.google.com/u/0/uc?id=ID_OF_FILE&export=download

然后选择“下载”或“随便下载”

就是这样