[英]Python PhantomJS using Selenium
Hello I want try load website with PhantomJS您好,我想尝试使用 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)
Here is the error这是错误
Traceback (most recent call last): File "/Users/martinzuffa/PycharmProjects/pythonProject/main.py", line 8, in driver = webdriver.PhantomJS(executable_path="/Users/martinzuffa/phantomjs-2.5.0-beta-macos/bin/phantomjs") File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 52, in init self.service.start() File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 96, in start self.assert_process_still_running() File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 107, in assert_process_still_running raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: Service /Users/martinzuffa/phantomjs-2.5.0-beta-macos/bin/phantomjs unexpectedly exited. Status code was: -9
回溯(最后一次调用):文件“/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 was deprecated in Selenium 3.8.1 PhantomJS 在Selenium 3.8.1中被弃用
* PhantomJS is now deprecated, please use either Chrome or Firefox in headless mode
* PhantomJS 现已弃用,请在无头模式下使用 Chrome 或 Firefox
Additionally, Selenium 4.1.0 packages doesn't contain the PhantomJS module anymore:此外, Selenium 4.1.0包不再包含PhantomJS模块:
As an alternative you have to use either of the following:作为替代方案,您必须使用以下任一方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.