Skip to content

Instantly share code, notes, and snippets.

@giuliano-macedo
Created October 25, 2020 21:34
Show Gist options
  • Save giuliano-macedo/5dca04e9f4aec74d9c20ce957a9674d7 to your computer and use it in GitHub Desktop.
Save giuliano-macedo/5dca04e9f4aec74d9c20ce957a9674d7 to your computer and use it in GitHub Desktop.
Shallow download files from Google drive folder using gdown and selenium
from bs4 import BeautifulSoup
from selenium import webdriver
import gdown
import argparse
parser=argparse.ArgumentParser()
parser.add_argument("url")
args=parser.parse_args()
options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(options=options)
print("geting files ids...")
driver.get(args.url);
soup=BeautifulSoup(driver.page_source,"lxml")
driver.close()
ids=[elem.attrs["data-id"] for elem in soup.select("[data-id]")]
print("downloading files...")
for id_ in ids:
gdown.download('https://drive.google.com/uc?id='+id_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment