Created
October 25, 2020 21:34
-
-
Save giuliano-macedo/5dca04e9f4aec74d9c20ce957a9674d7 to your computer and use it in GitHub Desktop.
Shallow download files from Google drive folder using gdown and selenium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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