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

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

我希望这里有人能帮忙!


当前回答

——更新

要下载该文件,请从这里获取python的youtube-dl:

YouTube-DL: https://rg3.github.io/youtube-dl/download.html

或者用pip安装:

sudo python2.7 -m pip install --upgrade youtube_dl 
# or 
# sudo python3.6 -m pip install --upgrade youtube_dl

更新:

我刚刚发现了这个:

右击要从drive.google.com下载的文件 点击获取共享链接 开启链路共享 点击共享设置 点击顶部下拉菜单的选项 点击更多 选择[x]打开-任何有链接的人 复制链接

https://drive.google.com/file/d/3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR/view?usp=sharing       
(This is not a real file address)

将id复制到https://drive.google.com/file/d/:之后

3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR

粘贴到命令行:

youtube-dl https://drive.google.com/open?id=

把id贴在后面?id =

youtube-dl https://drive.google.com/open?id=3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR
[GoogleDrive] 3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR: Downloading webpage
[GoogleDrive] 3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR: Requesting source file
[download] Destination: your_requested_filename_here-3PIY9dCoWRs-930HHvY-3-FOOPrIVoBAR
[download] 240.37MiB at  2321.53MiB/s (00:01)

希望能有所帮助

其他回答

这里有一个快速的方法。

确保链接是共享的,它看起来会像这样:

https://drive.google.com/open?id=FILEID&authuser=0

然后,复制该FILEID并像这样使用它

wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME

如果文件很大并且触发了病毒检查页面,您可以使用这样做(但它会下载两个文件,一个html文件和实际文件):

wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -r -A 'uc*' -e robots=off -nd

谷歌驱动器的默认行为是扫描文件的病毒,如果文件太大,它将提示用户,并通知他,该文件无法扫描。

目前我找到的唯一解决办法是在网络上共享文件并创建一个网络资源。

引用自谷歌驱动器帮助页面:

使用Drive,您可以使web资源-如HTML, CSS和Javascript文件-可作为网站查看。

使用Drive托管网页:

Open Drive at drive.google.com and select a file. Click the Share button at the top of the page. Click Advanced in the bottom right corner of the sharing box. Click Change.... Choose On - Public on the web and click Save. Before closing the sharing box, copy the document ID from the URL in the field below "Link to share". The document ID is a string of uppercase and lowercase letters and numbers between slashes in the URL. Share the URL that looks like "www.googledrive.com/host/[doc id] where [doc id] is replaced by the document ID you copied in step 6. Anyone can now view your webpage.

在这里找到:https://support.google.com/drive/answer/2881970?hl=en

例如,当你在谷歌驱动器上公开共享一个文件时,共享链接看起来是这样的:

https://drive.google.com/file/d/0B5IRsLTwEO6CVXFURmpQZ1Jxc0U/view?usp=sharing

然后复制文件id,创建googledrive.com链接,如下所示:

https://www.googledrive.com/host/0B5IRsLTwEO6CVXFURmpQZ1Jxc0U

2020年11月

如果你更喜欢使用bash脚本,这对我来说是有效的: (5Gb文件,已公开)

#!/bin/bash
if [ $# != 2 ]; then
echo "Usage: googledown.sh ID save_name"
exit 0
fi
confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='$1 -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
echo $confirm
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$confirm&id=$1" -O $2 && rm -rf /tmp/cookies.txt

2018年5月工作

嗨,根据这些评论…我创建一个bash导出URL列表从文件URL .txt到URLS_DECODED.txt 在一些加速器如flashget中使用(我使用cygwin来结合Windows和Linux)

引入命令爬行器是为了避免下载并(直接)获得最终链接

命令GREP HEAD和CUT,处理并获得最终链接,是基于西班牙语,也许你可以移植到英语语言

echo -e "$URL_TO_DOWNLOAD\r"可能\r只是cywin,必须用\n(换行符)代替

**********user***********为用户文件夹

*******Localización***********是西班牙语,清除星号,让英语单词定位和适应头部和切割数字适当的方法。

rm -rf /home/**********user***********/URLS_DECODED.txt
COUNTER=0
while read p; do 
    string=$p
    hash="${string#*id=}"
    hash="${hash%&*}"
    hash="${hash#*file/d/}"
    hash="${hash%/*}"
    let COUNTER=COUNTER+1
    echo "Enlace "$COUNTER" id="$hash
    URL_TO_DOWNLOAD=$(wget --spider --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='$hash -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id="$hash 2>&1 | grep *******Localización***********: | head -c-13 | cut -c16-)
    rm -rf /tmp/cookies.txt
    echo -e "$URL_TO_DOWNLOAD\r" >> /home/**********user***********/URLS_DECODED.txt
    echo "Enlace "$COUNTER" URL="$URL_TO_DOWNLOAD
done < /home/**********user***********/URLS.txt

使用youtube-dl !

优酷-DL https://drive.google.com/open?id=ABCDEFG1234567890

你也可以传递——get- URL来获取一个直接下载的URL。