-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_selenium.py
28 lines (26 loc) · 1.03 KB
/
setup_selenium.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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time
def goto(link):
driver.get('https://'+link)
time.sleep(3)
def xpath(s, a='one'):
if a=='all':
return driver.find_elements("xpath", s)
return driver.find_element("xpath", s)
def css_selector(s, a='one'):
if a=='all':
return driver.find_elements("css_selector", s)
return driver.find_element("css_selector", s)
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
# chrome_options.add_argument('--headless')
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.1234.567 Safari/537.36")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_experimental_option(
"prefs", {"profile.default_content_setting_values.notifications": 1}
)
driver = webdriver.Chrome(options=chrome_options)
driver.set_window_size(340, 620)
# driver = webdriver.Chrome()