我在使用库selenium在python中使用脚本运行执行Webdriver时遇到了问题。我发布了示例代码方案以及执行时抛出的相应错误。
代码情景:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
错误情景:
Traceback (most recent call last):
File "C:/Users/Kaushik/Desktop/IMC DEVELOPER TEST/Sample.py", line 4, in <module>
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\webdriver.py", line 59, in __init__
self.binary, timeout),
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 60, in launch_browser
self._start_from_profile_path(self.profile.path)
File "C:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\firefox\firefox_binary.py", line 83, in _start_from_profile_path
env=self._firefox_env).communicate()
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 87] The parameter is incorrect
我理解错误抛出了。我只需要使用selenium库使用python脚本从网站检索动态数据。
答案 0 :(得分:5)
您的代码没有任何问题,它适用于我。
你安装了firefox吗?如果没有,您可以使用其他浏览器。例如:
driver = webdriver.Ie
或
driver = webdriver.Opera