【发布时间】:2019-10-19 12:37:28
【问题描述】:
如何安装 Firefox 网络驱动程序以使用 selenium\python
我是用命令安装的
pip install selenium
我试过这段代码:
driver=webdriver.Firefox()
driver.get("https://www.google.com")
content=driver.find_element_by_id("lga")
print(content)
但它给了我这个错误
Traceback (most recent call last):
File "C:\Users\Acer\AppData\Local\Programs\Python\Python37-32\lib\site-package
s\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Acer\AppData\Local\Programs\Python\Python37-32\lib\subprocess.p
y", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Acer\AppData\Local\Programs\Python\Python37-32\lib\subprocess.p
y", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\Class.py", line 3, in <module>
class Scrape:
File ".\Class.py", line 4, in Scrape
driver = webdriver.Firefox()
File "C:\Users\Acer\AppData\Local\Programs\Python\Python37-32\lib\site-package
s\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\Acer\AppData\Local\Programs\Python\Python37-32\lib\site-package
s\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.
【问题讨论】:
标签: python-3.x windows selenium selenium-webdriver webdriver