-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebInitial.py
More file actions
23 lines (18 loc) · 969 Bytes
/
WebInitial.py
File metadata and controls
23 lines (18 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
def chrome_initialization(test):
chrome_options = Options()
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.add_argument('--acceptInsecureCerts')
chrome_options.add_argument('--start-maximized') # 启动时最大化窗口
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
if test == False:
chrome_options.add_argument('--headless')
os.environ['WDM_SSL_VERIFY'] = '0'
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
return driver