先安装:
最新的chrome
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
google-chrome --version
Google Chrome 93.0.4577.82
到 https://npm.taobao.org/mirrors/chromedriver/
下载相应的版本驱动:
wget https://npm.taobao.org/mirrors/chromedriver/93.0.4577.15/chromedriver_linux64.zip
#unzip chromedriver_linux64.zip
/usr/local/bin/目录下,并且赋可执行的权限:
#mv chromedriver /usr/local/bin/
#chmod -R 744 /usr/local/bin/chromedriver
#!/usr/bin/python37
#coding:utf8
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument(’–headless’)
options.add_argument(’–disable-gpu’)
options.add_argument(’–no-sandbox’)
driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver", options=options)
driver.get(“https://www.baidu.com”)
print(driver.page_source)
driver.quit()