尝试在Windows上使用Python捕获网页的屏幕截图时出错

时间:2017-03-15 14:02:16

标签: python

我在尝试在Python 3.6中捕获网页的屏幕截图时遇到错误。尝试跟随提出相同问题的其他帖子,但没有一个帮助。请指导我出错的地方。感谢。

代码:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.python.org/')
driver.save_screenshot('python_org.png')
driver.quit()

错误:

Traceback (most recent call last):
File "C:\Python36-32\lib\site-  packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Python36-32\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\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 "D:/screen_capture_3.py", line 3, in <module>
driver = webdriver.Firefox()
File "C:\Python36-32\lib\site-    packages\selenium\webdriver\firefox\webdriver.py", line 145, in __init__
self.service.start()
File "C:\Python36-32\lib\site-packages\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. 

0 个答案:

没有答案