【问题标题】:Python PhantomJS using Selenium使用 Selenium 的 Python PhantomJS
【发布时间】:2022-01-22 23:24:43
【问题描述】:

您好,我想尝试使用 PhantomJS 加载网站

from selenium import webdriver
driver = webdriver.PhantomJS(executable_path="/Users/martinzuffa/phantomjs-2.5.0-beta-macos/bin/phantomjs")
driver.get("www.google.com")
print(driver.page_source)

这是错误

Traceback(最近一次调用最后一次):文件 “/Users/martinzuffa/PycharmProjects/pythonProject/main.py”,第 8 行,在 driver = webdriver.PhantomJS(executable_path="/Users/martinzuffa/phantomjs-2.5.0-beta-macos/bin/phantomjs") 文件 “/usr/local/lib/python3.9/site-packages/selenium/webdriver/phantomjs/webdriver.py”, 第 52 行,在 init 中 self.service.start() 文件“/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py”, 第 96 行,开始 self.assert_process_still_running() 文件“/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py”, 第 107 行,在 assert_process_still_running 中 引发 WebDriverException(selenium.common.exceptions.WebDriverException:消息:服务 /Users/martinzuffa/phantomjs-2.5.0-beta-macos/bin/phantomjs 意外退出。状态码是:-9

【问题讨论】:

    标签: python selenium phantomjs selenium4 selenium-webdriver-python


    【解决方案1】:

    PhantomJS 在Selenium 3.8.1 中被弃用

    * PhantomJS 现已弃用,请在无头模式下使用 Chrome 或 Firefox

    此外,Selenium 4.1.0 包不再包含 PhantomJS 模块:


    解决方案

    作为替代方案,您必须使用以下任一方法:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-10
      • 1970-01-01
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-14
      相关资源
      最近更新 更多