|
1 |
| -# TODO: get last chromedriver version |
2 |
| -# TODO: get particular chromedriver version |
3 |
| -# TODO: download chromedriver and save to path |
4 |
| -# TODO: download and install chrome |
5 |
| -# TODO: argparse |
6 |
| -import zipfile |
7 |
| - |
8 |
| -import requests |
9 |
| - |
10 |
| -CHROMEDRIVER_URL = "https://chromedriver.storage.googleapis.com" |
11 |
| - |
12 |
| - |
13 |
| -def download_driver(link, extract_path="."): |
14 |
| - filename = link.split("/")[-1] |
15 |
| - r = requests.get(link, stream=True) |
16 |
| - with open(filename, "wb") as f: |
17 |
| - for chunk in r.iter_content(): |
18 |
| - f.write(chunk) |
19 |
| - with zipfile.ZipFile(filename, "r") as zf: |
20 |
| - zf.extractall(path=extract_path) |
21 |
| - |
22 |
| - |
23 |
| -def get_last_release(build=None) -> str: |
24 |
| - # TODO: if build is set get last version for this build |
25 |
| - if not build: |
26 |
| - r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE") |
27 |
| - else: |
28 |
| - r = requests.get(f"{CHROMEDRIVER_URL}/LATEST_RELEASE_{build}") |
29 |
| - return r.text |
30 |
| - |
31 |
| - |
32 |
| -def compose_download_link(build) -> str: |
33 |
| - return f"{CHROMEDRIVER_URL}/{build}/chromedriver_win32.zip" |
| 1 | +from webdriver_manager.chrome import ChromeDriverManager |
| 2 | +from selenium import webdriver |
34 | 3 |
|
| 4 | +def setup_chrome_driver(): |
| 5 | + driver = webdriver.Chrome(ChromeDriverManager().install()) |
| 6 | + return driver |
35 | 7 |
|
36 | 8 | if __name__ == "__main__":
|
37 |
| - release = get_last_release() |
38 |
| - download_link = compose_download_link(build=release) |
39 |
| - download_driver(download_link) |
| 9 | + driver = setup_chrome_driver() |
| 10 | + driver.quit() |
0 commit comments