linux/CentOS 安装firefox火狐浏览器配置无头模式

1、yum seach firefox
选择64位狐火浏览器安装
whereis firefox
查看安装目录

2、下载geckodriver
https://npm.taobao.org/mirrors/geckodriver/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
解压放到firefox安装目录
复制一份到/usr/bin ,省去指定路径

3、把firefox安装目录加入环境变量PATH
export PATH="$PATH:/usr/lib64/firefox"

4、测试使用

from selenium import webdriver

options = webdriver.FirefoxOptions()
options.add_argument('-headless')
driver = webdriver.Firefox(firefox_options=options)
driver.get('http://www.baidu.com')
title = driver.title
print('title:'+title)
now_url = driver.current_url
print('URL:' + now_url)
driver.close()

取消

感谢您的支持,我会继续努力哒!

扫码打赏
支付金额随意哦!

打开支付宝扫一扫,即可进行扫码打赏哦

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注