我是编程新手,但我想学习使用selenium模块。我为我的程序使用pycharm。我一直在跟随自动化无聊的东西与Python书。我曾尝试使用Firefox以及IE和Chrome。这是我在本书中给出的代码:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://nostarch.com')
和错误代码:
C:\Users\Matt\AppData\Local\Programs\Python\Python35\python.exe C:/Users/Matt/PycharmProjects/untitled/Bing.py
Traceback (most recent call last):
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\site- packages\selenium\webdriver\common\service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 1224, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Matt/PycharmProjects/untitled/Bing.py", line 5, in <module>
driver = webdriver.Firefox()
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
self.service.start()
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x000002C3D9235160>>
Traceback (most recent call last):
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File "C:\Users\Matt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
我已尝试过本网站上提供的其他一些建议,但无法让它发挥作用。感谢所有帮助