This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeckoDriver_Downloader.py
49 lines (36 loc) · 1.43 KB
/
GeckoDriver_Downloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
""""
===============]ZenMaxe[===============
| ZenMaxe Geckodriver Downloader v0.1 |
| No Copyright |
| Give Star On GitHub |
=======================================
"""
#import Libraries
import requests
import os
from bs4 import BeautifulSoup
def download_geckodriver(version, geckodriver_link):
if os.name == 'nt':
#Working on Windows Version
pass
else:
path = os.path.dirname(__file__)
geckodriver_linux = f"https://github.com/mozilla/geckodriver/releases/download/{version}/geckodriver-{version}-linux64.tar.gz"
#Download GeckoDriver with Wget command
os.system(f"wget {geckodriver_linux}")
#untar geckodriver
os.system(f"sudo tar -xvf ./geckodriver-{version}-linux64.tar.gz")
#make executable
os.system(f"sudo chmod +x geckodriver")
#add to path for selenium or you can enter geckodriver path manually on your selenium script
os.system(f"export PATH=$PATH:/{path}/geckodrive")
def main():
#get lastet version
geckodriver_link = "https://github.com/mozilla/geckodriver/releases/latest"
req = requests.get(geckodriver_link)
soup = BeautifulSoup(req.content, 'html.parser')
job_elements = soup.find("span",style="max-width: 125px" ).getText()
version = job_elements
download_geckodriver(version , geckodriver_link)
if __name__ == '__main__':
main()