How to download files or folders in google drive in python
- 1. Get a Direct Link for Your Google Drive Files
- 2. Install gdown
- 3. Download the file in google drive using Python
- 4. Download a folder in google drive using Python
1. Get a Direct Link for Your Google Drive Files
a. open Google Drive
b. Right-click on your file
c. Click on Get Link
d. Make sure your file is available for “Anyone with the link”
e. Click on Copy Link
!pip install gdown
import gdown
url = 'https://drive.google.com/file/d/1uFTzwFc3tmS-D7azjMiJcxSfn71BPqKt/view?usp=sharing'
output_path = 'graph_ML.pk'
gdown.download(url, output_path, quiet=False,fuzzy=True)
import gdown
url = "https://drive.google.com/drive/folders/1HWFHKCprFzR7H7TYhrE-W7v4bz2Vc7Ia"
gdown.download_folder(url, quiet=True, use_cookies=False)