How To Download Direct URL to Google drive using google Colab

 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

3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: How To Download Direct URL to Google drive using google Colab
How To Download Direct URL to Google drive using google Colab
DorHubs
https://dorhubs.blogspot.com/2020/10/how-to-download-direct-url-to-google.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2020/10/how-to-download-direct-url-to-google.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy