python - 无法连接到python3中的服务/usr/local/bin/geckodriver
问题描述
我的代码:
#!/usr/bin/python3
from selenium import webdriver
driver=webdriver.Firefox(executable_path=r'/usr/local/bin/geckodriver')
driver.get('http://www.python.org')
产生以下错误:
错误:消息:无法连接到服务 /usr/local/bin/geckodriver
我的设置:
- 火狐浏览器 81.0
- 操作系统 => 鹦鹉秒(Linux)
- Python 3.8.6
- 壁虎驱动 0.27.0
我怎样才能解决这个问题?
解决方案
将 geckodriver 文件移动到 /usr/bin ,然后更改代码如下。
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
希望它有帮助。它在我身边有效。
推荐阅读
- javascript - 如果键匹配,则将对象移动到子集
- c++ - 通用引用似乎不起作用,编译器将参数作为 r 值
- docker - 任何可行的方法来使用多个 GPU,多进程和 tensorflow?
- python - numpy eig 与 svd 。为什么他们会产生不同的结果
- mysql - 按以数字开头的字符串排序 - ActiveRecord
- php - 当 data_type 不匹配时,PDO 准备好的语句返回整个表
- javascript - 为什么我的数组没有在我的反应页面上呈现?
- php - Drupal PHP 字段剥离 HTML 标签
- sparql - 无法通过数据集绑定的 QueryExecution 访问命名图
- java - 是否可以从 POM 中的依赖项中排除传递运行时范围依赖项?