#这是我尝试使用铬驱动程序的代码
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
driver=webdriver.Chrome(r"/usr/local/bin/chromedriver")
#但错误即将到来..
<ipython-input-118-b695456c07d9>:6: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver=webdriver.Chrome(r"/usr/local/bin/chromedriver")
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-118-b695456c07d9> in <module>
4
5
----> 6 driver=webdriver.Chrome(r"/usr/local/bin/chromedriver")
3 frames
/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
114 def assert_process_still_running(self) -> None:
115 """Check if the underlying process is still running."""
--> 116 return_code = self.process.poll()
117 if return_code:
118 raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
AttributeError: 'Service' object has no attribute 'process'
我检查了Chrome和Chrome驱动程序的版本和路径。但我解决不了。我是一个真正的初学者,对Python不太了解,但是,我必须爬一些数据,但我甚至不能安装一个铬驱动程序。请帮帮我,Python大师
发布于 2022-12-01 14:42:25
在最新的Selenium版本中,executable_path已被废弃,因此您必须使用Service
from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(service=Service(<chromedriver.exe path>))
driver.get(<URL>)
https://stackoverflow.com/questions/74643146
复制相似问题