19

I am trying In Google Drive, how can you link directly to "Download" a zip file and not view the contents? but it does not work. I am not sure on how to repeat the question. It downloads a 'file is too big to be antivirus scanned' warning HTML and when I try https://drive.google.com/uc?export=download&confirm=no_antivirus&id= it still downloads that.

Edit: I tried to wget --save-cookies /tmp/cookie.txt --load-cookies /tmp/cookie.txt and repeat it, still no dice.

3
  • 1
    Did you ever figure this out? Running into the same problem with bigger files. Mar 18, 2014 at 19:31
  • No, I gave up on this.
    – chx
    Mar 18, 2014 at 20:50
  • 1
    Very similar question from Stack Overflow, with good answers: "wget/curl large file from google drive"
    – tanius
    Feb 8, 2019 at 14:40

5 Answers 5

7

A cookie must match the "confirm" url parameter, and it is changed on each call.

Here's a perl script to download these files in an unattended way.

With the url from the antivirus scan warning page (https://drive.google.com/uc?export=download&confirm=s5vl&id=XXX) this code should be enough:

#!/usr/bin/perl
use strict;
my $TEMP='/tmp';my $COMMAND;my $confirm;
sub execute_command();
my $URL=shift;my $FILENAME=shift;
$FILENAME='gdown' if $FILENAME eq '';
execute_command();
if (-s $FILENAME < 100000) { # only if file isn't the download yet
    open fFILENAME, '<', $FILENAME;
    foreach (<fFILENAME>) {
        if (/confirm=([^;&]+)/) {
            $confirm=$1; last;   }    }
    close fFILENAME;
    $URL=~s/confirm=([^;&]+)/confirm=$confirm/;
    execute_command();    }
sub execute_command() {
    $COMMAND="wget --no-check-certificate --load-cookie $TEMP/cookie.txt --save-cookie $TEMP/cookie.txt \"$URL\"";
    $COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne '';
    `$COMMAND`; return 1;    }
3
  • I've made a python script, and my cookie matches the confirm parameter in the url. However, it does not work: I am being redirected to a page titled "Sign in - Google Accounts". Feb 12, 2015 at 11:32
  • Benjamin: you may need to process the url twice... look how the script calls execute_command() twice. Mar 7, 2015 at 16:49
  • You can get the URL argument necessary for this script by doing: 1. Copy the Google Drive file link from the "Share" dialog (right-click on the file, then "Share"); 2. Go to Google Drive Direct Link Generator, paste the link in the text box, and click on "Create Direct Link"; 3. Copy the generated link and browse it; 4. Copy the link associated with the blue button with the label "Download anyway", and use it with this script. Jan 18, 2022 at 21:45
9

After spending many countless hours trying to get a direct download link that bypasses the virus scan I finally figured it out by accident. A URL in the format below along with your Google API key will bypass the virus scan. I could not find this documented anywhere (here is the official doc) so use at your own risk as future updates might break it. https://www.googleapis.com/drive/v3/files/fileid/?key=yourapikey&alt=media

1

Ok, Google uses the following URL format for the final download link:

https://drive.google.com/uc?export=download&confirm=s5vl&id=XXX

Notice the confirm parameter which seems to change every time you go to the original link. Maybe it's a short lived token or cookie matching or something?

0

Try this

You can download these files to your computer in the following formats:

For documents: HTML, RTF, Word, Open Office, PDF, Text file.
For spreadsheets: CSV, HTML, ODS, PDF, XLS, TXT (only for a single sheet)
For presentations: PDF, PPTX, TXT
For drawings: PNG, JPEG, SVG, PDF

Download a file to your computer from Google Drive

Click the checkbox(es) next to the item(s) that you'd like to download.
Expand the More drop-down menu, and select Download...
Select a file format to which you'd like convert and download your item, such as Microsoft Word. If you select multiple items, they'll be

compressed into a .zip file Click Download.

You can also download a file when you're viewing the file. Go to the File menu, point your mouse to Download as, and select a file format.

If total file is above 2GB I don't think you'll be able to download without breaking into batches.

1
  • alas, it's a binary file :( neither of the above.
    – chx
    Apr 25, 2013 at 2:05
0

I simply create a javascript so that it automatically capture the link and download and close the tab with the help of tampermonkey.

// ==UserScript==
// @name         Bypass Google drive virus scan
// @namespace    SmartManoj
// @version      0.1
// @description  Quickly get the download link
// @author       SmartManoj
// @match        https://drive.google.com/uc?id=*&export=download*
// @grant        none
// ==/UserScript==

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function demo() {
    await sleep(5000);
    window.close();
}

(function() {
    location.replace(document.getElementById("uc-download-link").href);
    demo();
})();

Not the answer you're looking for? Browse other questions tagged or ask your own question.