我想通过
from selenium import webdriver
driver = webdriver.Firefox()
读取火狐浏览器的网站,
报错:Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 74, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/liurukuo/Documents/测试.py", line 13, in
driver = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/firefox/webdriver.py", line 175, in init
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 84, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
在安装geckodriver时一直出错(selenium已经安装成功4.0),python版本3.9,Mac版本 Big Sur11.2.2,下载的gecko driver版本geckodriver-v0.30.0-macos-aarch64,在将文件移动至/usr/bin/时出错,无法移入,关闭sip后通过 sudo 更改写入状态 ,显示
mount_apfs: volume could not be mounted: Permission denied
mount: / failed with 66
求解!或者用其他方式可以用python读译网站也可以