使用Python脚本运行WebDriver时出错

 手机用户2702938421 发布于 2023-02-13 18:23

我在使用库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 
    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脚本从网站检索动态数据.

1 个回答
  • 您的代码没有任何问题,它对我来说很好.

    你有安装firefox吗?如果没有,您可以使用其他浏览器.例如:

    driver = webdriver.Ie 
    

    要么

    driver = webdriver.Opera
    

    2023-02-13 18:25 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有