您好我尝试运行用于打开浏览器的代码,在python中使用SPLINTER输入URL并关闭浏览器(https://splinter.readthedocs.io/en/latest/)。以上网址中的示例代码就是我尝试过的。
我收到了以下错误:
C:\Users\irgfff\Desktop>python browse.py
Traceback (most recent call last):
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
在处理上述异常期间,发生了另一个异常:
Traceback (most recent call last):
File "browse.py", line 4, in <module>
with Browser() as browser:
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\driver\webdriver\firefox.py", line 48, in __init__
timeout=timeout)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
self.service.start()
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver'
executable needs to be in PATH.
你可以让我知道我需要配置什么来避免这些错误吗?
我正在使用Python 3.6.1 Firefox版本 - 52 SPLINTER版本0.7.5
答案 0 :(得分:0)
我已经解决了这个问题。您必须添加PATH geckodriver和webdriver的位置。
您可以在此处下载geckodriver(https://github.com/mozilla/geckodriver/releases)。
祝你好运