file download from google drive to colaboratory

后端 未结 7 2146
遇见更好的自我
遇见更好的自我 2021-02-05 12:22

I was trying to download file from my google drive to colaboratory.

file_id = \'1uBtlaggVyWshwcyP6kEI-y_W3P8D26sz\'

import io
from googleapiclient.http import M         


        
7条回答
  •  失恋的感觉
    2021-02-05 13:01

    Here's an easy way to get by. You may either use wget command or requests module in Python to get the job done.

    # find the share link of the file/folder on Google Drive
    file_share_link = "https://drive.google.com/open?id=0B_URf9ZWjAW7SC11Xzc4R2d0N2c"
    
    # extract the ID of the file
    file_id = file_share_link[file_share_link.find("=") + 1:]
    
    # append the id to this REST command
    file_download_link = "https://docs.google.com/uc?export=download&id=" + file_id 
    

    The string in file_download_link can be pasted in the browser address bar to get the download dialog box directly.

    If you use the wget command:

    !wget -O ebook.pdf --no-check-certificate "$file_download_link"
    

提交回复
热议问题