Linux使用Selenium

下载google
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
查看google版本
google-chrome --version
安装必要的库
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
安装chromedriver
  • 在这个里面找你的对应的版本:https://registry.npmmirror.com/binary.html?path=chromedriver/

    wget https://chromedriver.storage.googleapis.com/版本/chromedriver_linux64.zip
    
  • 装好之后就地解压:

    unzip chromedriver_linux64.zip
    
  • 然后将解压的chromedriver移动到 /usr/bin目录下:

    mv chromedriver /usr/bin/
    
  • 给与执行权限:

    chmod +x /usr/bin/chromedriver
    
  • 检查chromedriver版本:

    chromedriver -version
    

使用

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')
browser = webdriver.Chrome(chrome_options=chrome_options)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值