0
点赞
收藏
分享

微信扫一扫

centos 安装 chromedriver

言午栩 2022-04-01 阅读 167
爬虫

(一)安装浏览器

1、curl https://intoli.com/install-google-chrome.sh | bash
2、ldd /opt/google/chrome/chrome | grep "not found”
3、google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com

(二)安装chromedriver

1、yum install chromedriver.x86_64

(三)测试

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('window-size=1920x3000')
chrome_options.add_argument('--hide-scrollbars')
chrome_options.add_argument('blink-settings=imagesEnabled=false')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu’)
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com”)
print(driver.page_source)

打印出网页源码即成功

举报

相关推荐

0 条评论