Download Google Drive file using python 3

Vaibhav Mishra
1 min readMar 23, 2020

This is blog for those people who wants to automate everything and loves python. The purpose of this blog to automate download Google drive text file from python code using gdown module. In one of my project I had requirement to download log.txt file from Google Drive and then show that file in VMs. I have multiple VMs and in every VM I want same log file. I can’t go all the time to Google Drive UI and click on Download it with every VMs.

There are multiple steps to download the file.
Step1: To get downloadable link of that file:
a: Go to that file and take get shareable link.
b: Take id of the that file.
c: make downloadable link by concatenate id with https://drive.google.com/uc?export=download&id="your_file_id"

Python Code:

import gdown
url = ‘https://drive.google.com/uc?export=download&id=Your_file_id'
output= ‘Demotest.txt’
gdown.download(url, output, quiet=False, proxy=False)

The output of that file is stored in Demotest.txt at same location. Make sure you have installed gdown module using pip3 install gdown.

Happy Coding…..

--

--

Vaibhav Mishra

I am passionate software developer working in different technologies like Python, ML, Django and JavaScript.