Traceback (most recent call last):
File "D:/spider/aa/brand.py", line 9, in <module>
browser = webdriver.Firefox() # 打开浏览器
File "C:\ProgramData\Anaconda3\envs\spider\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 157, in __init__
self.service.start()
File "C:\ProgramData\Anaconda3\envs\spider\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.
这个是因为selenium3.0启动firefox需要geckodriver.exe这个驱动文件。
下载地址:https://github.com/mozilla/geckodriver/releases
下载之后,配置到环境变量path下(可以直接放python根目录)
网友评论