centos安装chrome,使用selenium

1.安装chrome

yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

2.查看chrome版本

google-chrome --version

驱动下载

wget https://chromedriver.storage.googleapis.com/91.0.4472.101/chromedriver_linux64.zip

3.centos selenium使用无头模式

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(options=chrome_options,executable_path=os.path.join(os.getcwd(),'utils/chromedriver'))
driver.get('http://192.168.16.128:9528/core/auth/login/')

windows selenium使用无头模式

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=chrome_options,executable_path=os.path.join(os.getcwd(),'utils/chromedriver.exe'))
driver.get('http://192.168.16.128:9528/core/auth/login/')

你可能感兴趣的:(chrome,centos,selenium)