Skip to content

Commit 98a0936

Browse files
committed
check provided driver
1 parent f05e41e commit 98a0936

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

selenium/selenium_headless_stealth.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
import undetected_chromedriver as uc
33
from selenium.webdriver.common.by import By
44
from selenium.webdriver.chrome.options import Options
5+
from selenium.webdriver.chrome.service import Service
56
import sys
67
import argparse
78
import tty, termios
8-
import json # Add this import at the top
9-
import os # new import
9+
import json
10+
import os
11+
12+
WEBDRIVER_PATH = os.environ.get("CHROME_DRIVER")
1013

1114
def getch():
1215
fd = sys.stdin.fileno()
@@ -73,6 +76,7 @@ def str2bool(value):
7376
GEO_LONGITUDE = 11.576124
7477
GEO_ACCURACY_M = 50
7578

79+
7680
cdp_commands = {
7781
"Emulation.setTimezoneOverride" : {"timezoneId": TIMEZONE_ID},
7882
"Emulation.setLocaleOverride" : {"locale": LANGUAGE},
@@ -94,7 +98,11 @@ def str2bool(value):
9498
os.makedirs(PROFILE_DIR, exist_ok=True)
9599
chrome_options.add_argument(f"--user-data-dir={PROFILE_DIR}")
96100

97-
driver = uc.Chrome(options=chrome_options)
101+
if WEBDRIVER_PATH:
102+
service = Service(WEBDRIVER_PATH)
103+
driver = uc.Chrome(service=service, options=chrome_options)
104+
else:
105+
driver = uc.Chrome(options=chrome_options)
98106

99107
for each_command in cdp_commands:
100108
driver.execute_cdp_cmd(each_command, cdp_commands[each_command])

0 commit comments

Comments
 (0)