问答 一个小小的疑问,使用 selenium4,启动 chrome 浏览器错误

行吧,就这样吧 · 2022年10月21日 · 最后由 憨憨李四 回复于 2023年08月06日 · 11259 次阅读

使用 selenium3 版本的时候

安装 selenium

pip install selenium==3.11.0

使用

from selenium import webdriver

driver = webdriver.Chrome(executable_path='chromedriver')
driver.get('https://www.baidu.com')

可以正常打开浏览器

最新想使用一下这个undetected-chromedriver
但是这个库最低得使用 selenium4.0 以上的版本

所有就更新了一下 selenium 版本

pip install --upgrade selenium

最后,就导致了使用 selenium 打不开浏览器的情况

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

driver = webdriver.Chrome(service=Service('chromedriver'))

就打不开了,500 Internal Privoxy Error

大佬们,有解决方法吗?

Traceback (most recent call last):
  File "/Users/Desktop/pythonProject/ttt.py", line 16, in <module>
    driver = webdriver.Chrome(service=Service('chromedriver'))
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
    super().__init__(
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 272, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 364, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File "/Users/Desktop/pythonProject/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 207, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: <html>
<head>
 <title>500 Internal Privoxy Error</title>
 <link rel="shortcut icon" href="http://config.privoxy.org/error-favicon.ico" type="image/x-icon"></head>
<body>
<h1>500 Internal Privoxy Error</h1>
<p>Privoxy encountered an error while processing your request:</p>
<p><b>Could not load template file <code>no-server-data</code> or one of its included components.</b></p>
<p>Please contact your proxy administrator.</p>
<p>If you are the proxy administrator, please put the required file(s)in the <code><i>(confdir)</i>/templates</code> directory.  The location of the <code><i>(confdir)</i></code> directory is specified in the main Privoxy <code>config</code> file.  (It's typically the Privoxy install directory, or <code>/etc/privoxy/</code>).</p>
</body>
</html>
共收到 9 条回复 时间 点赞

看情况估计是你驱动路径指定的问题 ,贴个绝对路径上去试试看

Tester_谜城 回复

不是路径的问题,chromedriver 我是放在文件相同路径下,我也尝试了绝对路径,都不行的

郭有权 回复

嗯,对,是的,收到

5楼 已删除

好奇,楼上咋突然对了

1、核对 chromedriver 版本与浏览器版本是否一致
2、检查代码

版本、路径 常见的两种问题

你是不是开了代理?抓包工具打开的情况下 好像也会影响到程序执行

Selenium4 有专门的驱动模块,会自动给你下载相应的驱动,可以参考我写的文章http://t.csdn.cn/l01Qk

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册