大家好,我想制作一款需要chromedriver和我使用命令行下载了chrome webdriver和导入的硒。我在路径中添加了webdriver并指定了位置,但weeoes显示无法找到该文件,而chromedriver需要在路径中]
如果有人需要提供更多信息,我们很乐意为您提供帮助,我非常感谢有人尝试为我测试代码,请告诉我,以便我可以在github上分享它
subprocess.py
self._execute_child(args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) hp, ht, pid, tid = _winapi.CreateProcess(executable, args, # no special security None, None, int(not close_fds), creationflags, env, cwd, startupinfo)
service.py
self.process = subprocess.Popen(cmd, env=self.env, close_fds=platform.system() != 'Windows', stdout=self.log_file, stderr=self.log_file, stdin=PIPE) raise WebDriverException( "'%s' executable needs to be in PATH. %s" % ( os.path.basename(self.path), self.start_error_message
Webdriver.py
self.service = Service( executable_path, port=port, service_args=service_args, log_path=service_log_path) self.service.start()
Davids_Chegg.py
chrome_driver = r'C:\Webdrivers\chromedriver.exe\' if __name__ == '__main__': browser = webdriver.Chrome("C:\Webdrivers\chromedriver.exe") signin() client.run(bot_token) # test comment
ERRORS: Traceback (most recent call last): File "C:\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Python38\lib\subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Python38\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Users\david\Desktop\Python\chegg_bot\David_s Chegg.py", line 282, in <module> browser = webdriver.Chrome(executable_path="chromedriver", options=opts) File "C:\Python38\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "C:\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
大家好,我试图制造一个需要chromedriver的Chegg机器人,我用命令行下载了chrome webdriver和导入的硒。我在路径中添加了网络驱动程序,并指定了...
您可以尝试下面的代码,无需担心路径设置或根据Web浏览器版本安装Webdriver。