我正在尝试使用python和selenium制作一个web自动化机器人,但我遇到了一个问题/错误。
这是我的密码
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/driverchromedriver.exe')
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)这是我遇到的错误
Traceback (most recent call last):
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\asus\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified发布于 2021-12-24 19:04:30
这个错误信息..。
FileNotFoundError: [WinError 2] The system cannot find the file specified...implies表示程序找不到上述可执行文件driverchromedriver.exe
可能是一个错误,就像它的原始形式一样,ChromeDriver可执行文件的名称是
解决方案
实际上,相关的代码行将是:
如果
C:/Users/asus/AppData/Local/Programs/Python/Python39/中,则为:s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/chromedriver.exe')
如果
C:/Users/asus/AppData/Local/Programs/Python/Python39/driver/中,则为:s=Service('C:/Users/asus/AppData/Local/Programs/Python/Python39/driver/chromedriver.exe')
https://stackoverflow.com/questions/70462971
复制相似问题