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

我在网上搜了很多,终于下载了其中一个。我得到了文件的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,但这不起作用。

我希望这里有人能帮忙!


当前回答

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

下面是我如何使用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

其他回答

这是我从谷歌驱动器下载文件到我的谷歌云Linux外壳的解决方案。

使用高级共享将文件共享给PUBLIC并具有Edit权限。 你会得到一个共享链接,它会有一个ID。参见链接:- drive.google.com/file/d/ (ID) /视图? usp =分享 复制该ID并粘贴在以下链接:-

googledrive.com/host/ (ID)

以上链接为我们的下载链接。 使用wget下载文件:-

wget https://googledrive.com/host/ [ID]

该命令将下载名称为[ID]的文件,没有扩展名,但文件大小与运行wget命令的位置相同。 实际上,我在实习时下载了一个压缩文件夹。所以我重命名了这个尴尬的文件使用:-

mv [id] 1.zip

然后使用

1.压缩解压缩

我们会拿到文件的。

有一个开源的多平台客户端,用Go: drive编写。它非常漂亮,功能齐全,而且还在积极开发中。

$ drive help pull
Name
        pull - pulls remote changes from Google Drive
Description
        Downloads content from the remote drive or modifies
         local content to match that on your Google Drive

Note: You can skip checksum verification by passing in flag `-ignore-checksum`

* For usage flags: `drive pull -h`

2022年6月

你可以用gdown。也可以考虑访问该页面以获得完整的说明;这只是一个总结,源回购可能有更多最新的说明。


指令

使用以下命令安装:

pip install gdown

在此之后,您可以通过运行以下命令之一从谷歌驱动器下载任何文件:

gdown https://drive.google.com/uc?id=<file_id>  # for files
gdown <file_id>                                 # alternative format
gdown --folder https://drive.google.com/drive/folders/<file_id>  # for folders
gdown --folder --id <file_id>                                   # this format works for folders too

示例:从该目录下载自述文件

gdown https://drive.google.com/uc?id=0B7EVK8r0v71pOXBhSUdJWU1MYUk

file_id应该类似于0Bz8a_Dbh9QhbNU3SGlFaDg。您可以通过右键单击感兴趣的文件并选择Get link来找到这个ID。自2021年11月起,该链接的形式为:

# Files
https://drive.google.com/file/d/<file_id>/view?usp=sharing
# Folders
https://drive.google.com/drive/folders/<file_id>

警告

只对开放文件有效。(“任何有链接的人都可以查看”) 不能下载超过50个文件到一个文件夹。 如果您可以访问源文件,您可以考虑使用tar/zip将其变成一个单独的文件来解决这个限制。

对于无意中发现这条线索的任何人,以下工作截至2022年5月,以绕过大文件的反病毒检查:

#!/bin/bash
fileid="FILEIDENTIFIER"
filename="FILENAME"
html=`curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}"`
curl -Lb ./cookie "https://drive.google.com/uc?export=download&`echo ${html}|grep -Po '(confirm=[a-zA-Z0-9\-_]+)'`&id=${fileid}" -o ${filename}

截至2016年12月,没有任何答案能告诉我什么适合我(来源):

curl -L https://drive.google.com/uc?id={FileID}

前提是谷歌驱动器文件已经与那些拥有该链接的人共享,并且{FileID}是共享URL中?id=后面的字符串。

虽然我没有检查过大的文件,但我相信知道它可能是有用的。