当使用selenium和phantomJS时,我得到了一个WinError 87。

时间:2017-10-29 14:13:22

标签: selenium phantomjs

我的Windows 10中有selenium 3.6.0和phantomjs-2.1.1-windows,并将PATH设置为phantomJS.exe。当我使用下面的代码时:

driver = webdriver.PhantomJS(executable_path='')

我弄错了:

Traceback (most recent call last):
File "D:\Python 3.5.4\test\BeautifulSoup.py", line 10, in <module>
driver = webdriver.PhantomJS(executable_path='')
File "C:\Program Files\Python35\lib\site-
packages\selenium\webdriver\phantomjs\webdriver.py", line 52, in __init__
self.service.start()
File "C:\Program Files\Python35\lib\site-
packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Program Files\Python35\lib\subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python35\lib\subprocess.py", line 957, in 
_execute_child
startupinfo)
OSError: [WinError 87] wrong parameters。

1 个答案:

答案 0 :(得分:1)

抱歉令人不安。实际上当我将phantomJS.exe设置为$ PATH时。我实际上在webdriver.PhantomJS()中不需要任何参数。我找到了以下文档:     executable_path - 可执行文件的路径。如果使用默认值,则假定可执行文件位于$ PATH