A python scripts that uses Google Drive API to download folders or files.
- Git clone this repo:
git clone https://github.com/Techyhans/google-api-scraping.git
- Create an Python 3.8.5 >= environment:
conda create -n gdrive-api python=3.10.9
conda activate gdrive-api
- Install required dependencies:
pip install -r requirements.txt
Open Google Console and write Google Drive API to search bar. Click Create Credentials / OAuth Client ID then create your project. After download your client_secretXXX.json file and save it as "client_secret.json"
You may state two arguments to run the download.py
.
- '-l' or '--link': One or more files or folders sharable link you would like to download (Must be given)
- '-i' or '--id': One or more files or folders ID you would like to download (Must be given)
- '-n' or '--name': One or more folder names you would like to search and download in given parent folder ID (Optional)."
For example:
- To download a folder with all items it contains, specifying its sharable links as below:
python download.py -l https://drive.google.com/file/d/1ZKWjVjYAgjKbLYviQFCwT0HfuDwGweCq/view?usp=share_link
- To download multiple folders:
python download.py -i DRIVE_LINK1 DRIVE_LINK2 ...
- If you want to download a file only. Also, you only have to provide the ID.
- To search folder with folder name
folder_1
under the parent folder with given ID:
python download.py -i DRIVE_LINK -n folder_1
This would only download the folder_1
folder with all its content. You may specific multiple IDs and names.