I have given you the source code of doing this using google colab.
Step 1:
First thing you need to do is to connect the colab notebook to google drive.
from google.colab import drive
drive.mount('/content/drive')
Step 2:
In this step you put the main downloading code in the colab notebook. Which is the most important part.
"""
@author:Satyajit Talukder
Noakhali Science and Technology University
"""
import requests
from tqdm import tqdm
download_dir = ""#@param {type:"string"}
file_url = ""#@param {type:"string"}
fileName=""#@param{type:"string"}
r = requests.get(file_url, stream = True)
fileo=download_dir+"/"+fileName
total_size=int(r.headers["content-length"])
chunk_size = 1024
with open(fileo, "wb") as file:
for block in tqdm(r.iter_content(chunk_size),total = total_size/chunk_size, unit = 'KB',position=0,desc=fileName):
if block:
file.write(block)
print("Download complete!")
In this code tqdm library is used to give a nice downloading status with download speed
Documentation:
- download_dir : It means in which directory the file will be downloaded in the google drive
- file_url: It means the download link of the file
- fileName: It is the give the file a specific name