簡體   English   中英

Python PhantomJS 使用 Selenium

[英]Python PhantomJS using Selenium

您好,我想嘗試使用 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)

這是錯誤

回溯(最后一次調用):文件“/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 行,在 start 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

PhantomJS 在Selenium 3.8.1中被棄用

* PhantomJS 現已棄用,請在無頭模式下使用 Chrome 或 Firefox

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

Python模塊


解決方案

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM