linux安装selenium+chrome
发布时间:2020-12-14 01:52:44 所属栏目:Linux 来源:网络整理
导读:1. 安装 selenium pip3 install selenium pip3 安装参考 2. 安装 ChromeDriver yum install chromedriver.x86_64 3. 安装 Chrome 配置源,终端复制执行下面的代码 cat EOF /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseurl=h
1. 安装 seleniumpip3 install selenium 2. 安装 ChromeDriveryum install chromedriver.x86_64 3. 安装 Chrome
cat << EOF > /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1 gpgcheck=1 gpgkey=https://dl.google.com/linux/linux_signing_key.pub EOF
4.测试from selenium import webdriver driver = webdriver.Chrome() driver.get(‘http://www.baidu.com/‘) print( driver.title ) driver.quit()
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(chrome_options=chrome_options) driver.get(‘http://www.baidu.com/‘) print( driver.title ) driver.quit()
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |