Ubuntu 系统下 运行python,调用火狐浏览器来抓取数据问题

程序如下:
from selenium import webdriver

browser = webdriver.Firefox()
运行结果如下:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/common/service.py", line 76, in start

stdin=PIPE)

File "/usr/lib/python3.4/subprocess.py", line 859, in init

restore_signals, start_new_session)

File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child

raise child_exception_type(errno_num, err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 3, in <module>

browser = webdriver.Firefox()

File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in init

self.service.start()

File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/common/service.py", line 83, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
请问是什么问题呢???

阅读 3.4k
2 个回答

它说你没有火狐的驱动程序,那个Path路径是火狐浏览器驱动程序的位置,而不是火狐浏览器的位置,自己去网上下载一个就是了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题