Cookie百度案例:代码与老师的完全一致,不知为什么报错。 报错日志如下:
D:\python\python.exe C:/Users/liufeilong/Desktop/Cookie/cookie.py Traceback (most recent call last): File "D:\python\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start stdin=PIPE) File "D:\python\lib\subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "D:\python\lib\subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:/Users/liufeilong/Desktop/Cookie/cookie.py", line 5, in <module> driver = webdriver.Firefox() File "D:\python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__ self.service.start() File "D:\python\lib\site-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. Process finished with exit code 1
回答
JYONG回答
错误提示中有"geckodriver"字样,说明你的火狐浏览器自动更新到了更高的版本;selenium2.48.0要配合火狐35版本使用才可以;
如果火狐浏览器更新到了高级版本,就需要下载geckodriver.exe驱动;
建议你卸载火狐,并重新安装火狐35版本;安装过程中要注意,断网安装并按照以下步骤,确保安装后不会再自动更新
(0)