我在python文件中导入了selenium模块但是当我运行这段代码时我得到了
Traceback (most recent call last):
File "koovs.py", line 4, in <module>
browser=webdriver.Firefox()
File "C:\Users\hp\Anaconda2\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 140, in __init__
self.service.start()
File "C:\Users\hp\Anaconda2\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.
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of
<selenium.webdriver.firefox.service.Service object at 0x0000000003228400>> ignored
我必须做什么。我的代码是
from selenium import webdriver
from bs4 import BeautifulSoup
browser=webdriver.Firefox()
browser.get('http://www.koovs.com/women/dresses/sortby-discount-high/')
soup=BeautifulSoup(browser.page_source)
答案 0 :(得分:1)
您安装了geckodriver
吗?
要使用Firefox webdriver,您必须安装geckodriver
。并将二进制文件放入可由系统PATH访问的文件夹中。
答案 1 :(得分:0)
转到the link并根据您的geckodriver
下载windows 32 or 64 bit
。
将geckodriver.exe解压缩到您的计算机,并将相应的路径添加到环境变量中。
例如:如果您将geckodriver.exe解压缩到桌面,则应将桌面路径添加到Path Env.
变量。
然后重新执行您的代码。有时环境我不反思。在这种情况下,您可能需要重新启动IDE(如Eclipse)。
希望它有所帮助。