为什么selenium模块不能打开浏览器?
这是我想用selenium模块打开火狐浏览器,为什么会报错呢?from selenium import webdriver
>>> browser = webdriver.Firefox()
Traceback (most recent call last):
File "D:\python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "D:\python\Python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\python\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
browser = webdriver.Firefox()
File "D:\python\Python38\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 166, in __init__
self.service.start()
File "D:\python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
你下载驱动了吗
你的驱动在系统path里吗 wp231957 发表于 2020-4-9 19:25
你下载驱动了吗
你的驱动在系统path里吗
一脸懵逼,啥意思? duke0522 发表于 2020-4-9 19:30
一脸懵逼,啥意思?
百度一下,你需要下载火狐浏览器,以及与其配对的驱动, 1. 安装selenium
Win:pip install selenium
Mac:pip3 install selenium
2. 安装webdriver
各大浏览器webdriver地址可参见:https://docs.seleniumhq.org/download/
Firefox:https://github.com/mozilla/geckodriver/releases/
Chrome:https://sites.google.com/a/chromium.org/chromedriver/ 或者
http://chromedriver.storage.googleapis.com/index.html
IE:http://selenium-release.storage.googleapis.com/index.html
注:webdriver需要和对应的浏览器版本以及selenium版本对应
Webdriver版本 支持的Chrome版本
v2.41 v67-69
v2.40 v66-68
v2.39 v66-68
v2.38 v65-67
v2.37 v64-66
v2.36 v63-65
v2.35 v62-64
v2.34 v61-63
v2.33 v60-62
3. webdriver安装路径
Win:复制webdriver到Python安装目录下
Mac:复制webdriver到/usr/local/bin目录下
疾风怪盗 发表于 2020-4-9 19:34
1. 安装selenium
Win:pip install selenium
Mac:pip3 install selenium
谢谢,后来发现,直接启动Edge就可以了,驱动是自带的 疾风怪盗 发表于 2020-4-9 19:34
1. 安装selenium
Win:pip install selenium
Mac:pip3 install selenium
链接都打不开啊。。。
页:
[1]