-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,10 @@ | ||
# TODO: get last chromedriver version | ||
# TODO: get particular chromedriver version | ||
# TODO: download chromedriver and save to path | ||
# TODO: download and install chrome | ||
# TODO: argparse | ||
import zipfile | ||
|
||
import requests | ||
|
||
CHROMEDRIVER_URL = "https://chromedriver.storage.googleapis.com" | ||
|
||
|
||
def download_driver(link, extract_path="."): | ||
filename = link.split("/")[-1] | ||
r = requests.get(link, stream=True) | ||
with open(filename, "wb") as f: | ||
for chunk in r.iter_content(): | ||
f.write(chunk) | ||
with zipfile.ZipFile(filename, "r") as zf: | ||
zf.extractall(path=extract_path) | ||
|
||
|
||
def get_last_release(build=None) -> str: | ||
# TODO: if build is set get last version for this build | ||
if not build: | ||
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE") | ||
else: | ||
r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE_{build}") | ||
return r.text | ||
|
||
|
||
def compose_download_link(build) -> str: | ||
return f"{CHROMEDRIVER_URL}/{build}/chromedriver_win32.zip" | ||
from webdriver_manager.chrome import ChromeDriverManager | ||
from selenium import webdriver | ||
|
||
def setup_chrome_driver(): | ||
driver = webdriver.Chrome(ChromeDriverManager().install()) | ||
return driver | ||
|
||
if __name__ == "__main__": | ||
release = get_last_release() | ||
download_link = compose_download_link(build=release) | ||
download_driver(download_link) | ||
driver = setup_chrome_driver() | ||
driver.quit() |