首先安裝google的epel源html
vi /etc/yum.repos.d/google.repo [google] name=Google-x86_64 baseurl=http://dl.google.com/linux/rpm/stable/x86_64 enabled=1 gpgcheck=0 gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
yum update , 而後yum install google-chrome-stablepython
https://npm.taobao.org/mirrors/chromedriver/linux
找到chrome對應的chromedriver 版本,並下載web
wget https://chromedriver.storage.googleapis.com/74.0.3729.6/chromedriver_linux64.zip
將下載的chromedriver 放到腳本同級目錄調用chrome
chmod 755 chromedriver
npm
from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--no-sandbox') # 禁止沙箱模式,不然肯能會報錯遇到chrome異常 url="https://www.west.cn/login.asp" brower=webdriver.Chrome(executable_path="./chromedriver", chrome_options=chrome_options) brower.get(url) print(brower.current_url) brower.get("https://www.west.cn/Manager/") print(brower.current_url) brower.quit()
參考連接:centos
centos 7 無gui界面運行selenium + chrome模擬登錄api