forked from anilabhadatta/educative.io_scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchromedriver.py
36 lines (29 loc) · 1020 Bytes
/
chromedriver.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
import sys
import os
import platform
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
def get_binary_path():
current_os = sys.platform
if current_os.startswith('darwin'):
if platform.machine() == 'x86_64':
chromedriver = r'mac_x86_64/chromedriver'
else:
chromedriver = r'mac_arm64/chromedriver'
elif current_os.startswith('linux'):
if platform.machine() == 'aarch64':
chromedriver = r'linux_arm64/chromedriver'
else:
chromedriver = r'linux_amd64/chromedriver'
elif current_os.startswith('win32') or current_os.startswith('cygwin'):
chromedriver = r'win\chromedriver.exe'
return chromedriver
def load_chromedriver():
try:
chromedriver = get_binary_path()
chromedriver_path = os.path.join(
ROOT_DIR, "Chrome-driver", chromedriver)
os.system(chromedriver_path)
except KeyboardInterrupt:
sys.exit()
if __name__ == '__main__':
load_chromedriver()