radio selium 找不到_selenium学习问题,找不到解决方法了

在尝试使用Python的Selenium库和PhantomJS浏览器驱动进行网页自动化时,遇到了错误。错误信息表明系统无法找到指定的PhantomJS执行文件。问题可能出在PhantomJS的路径设置上,或者文件不存在。解决方案包括检查PhantomJS的安装路径是否正确,确保文件在指定路径下,并且在环境变量中添加该路径。
摘要由CSDN通过智能技术生成

from selenium import webdriver

print(0)

driver = webdriver.PhantomJS(executable_path='E:\phantomjs-2.1.1-windows\bin')

print(1)

driver.get('http://www.baidu.com')

print(2)

print(driver.title)

出错了:

0

Traceback (most recent call last):

File "E:PythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 64, in start

stdout=self.log_file, stderr=self.log_file)

File "E:PythonPython35-32libsubprocess.py", line 947, in init

restore_signals, start_new_session)

File "E:PythonPython35-32libsubprocess.py", line 1224, in _execute_child

startupinfo)

FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:/Users/ty/PycharmProjects/untitled3/src/Reptile.py", line 20, in

driver = webdriver.PhantomJS(executable_path='E:\phantomjs-2.1.1-windows\bin')

File "E:PythonPython35-32libsite-packagesseleniumwebdriverphantomjswebdriver.py", line 52, in init

self.service.start()

File "E:PythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 71, in start

os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'phantomjs-2.1.1-windowsin' executable needs to be in PATH.

Exception ignored in: >

Traceback (most recent call last):

File "E:PythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 163, in del

self.stop()

File "E:PythonPython35-32libsite-packagesseleniumwebdrivercommonservice.py", line 135, in stop

if self.process is None:

AttributeError: 'Service' object has no attribute 'process'

找不到问题出哪

就到webdriver.PhantomJS这一行出错。

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值