我试图在脚本中从谷歌驱动器下载一个文件,我这样做有点麻烦。我要下载的文件在这里。
我在网上搜了很多,终于下载了其中一个。我得到了文件的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,但这不起作用。
我希望这里有人能帮忙!
谷歌驱动器的默认行为是扫描文件的病毒,如果文件太大,它将提示用户,并通知他,该文件无法扫描。
目前我找到的唯一解决办法是在网络上共享文件并创建一个网络资源。
引用自谷歌驱动器帮助页面:
使用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年
适用于无头服务器。我试图下载一个200GB的私人文件,但无法获得任何其他方法,在这个线程中提到,工作。
解决方案
(如果文件已经在您自己的谷歌驱动器中,则跳过此步骤)将想要从公共/共享文件夹下载的文件复制到您的谷歌驱动器帐户中。选择“文件”->右键单击->拷贝
安装Rclone(一个开源命令行工具),在本地存储和谷歌驱动器之间同步文件。这是一个快速教程,安装和设置rclone的谷歌驱动器。
使用Rclone将您的文件从谷歌驱动器复制到您的机器
rclone copy mygoogledrive:path/to/file /path/to/file/on/local/machine -P
-P参数帮助跟踪下载的进度,并让您知道下载何时完成。