简体   繁体   English

通过 Selenium 和 Python 使用代理的 ChromeDriver 日志中的错误

[英]Errors in ChromeDriver logs using a proxy through Selenium and Python

I am trying to test how to use proxies using selenium in python Here's the code I am trying我正在尝试测试如何在 python 中使用 selenium 使用代理这是我正在尝试的代码

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

PROXY = "164.68.123.119:9300"
opts = Options()
#opts.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(executable_path="D:/Webdrivers/chromedriver.exe", options=opts)

print(type(driver))
driver.get("https://www.google.com")
myPageTitle=driver.title
print(myPageTitle)
assert "Google" in myPageTitle
time.sleep(10)
print(driver.quit)
driver.quit()

When running the code without relying on the proxy, I got error logs like that在不依赖代理的情况下运行代码时,我得到了这样的错误日志

DevTools listening on ws://127.0.0.1:1056/devtools/browser/3bd3f85f-6d2c-4273-87be-a2e108c07626
<class 'selenium.webdriver.chrome.webdriver.WebDriver'>
Google
[10116:7976:1029/180608.508:ERROR:chrome_browser_main_extra_parts_metrics.cc(230)] crbug.com/1216328: Checking Bluetooth availability started. Please report if there is no report that this ends.
[10116:7976:1029/180608.509:ERROR:chrome_browser_main_extra_parts_metrics.cc(233)] crbug.com/1216328: Checking Bluetooth availability ended.
[10116:10692:1029/180608.527:ERROR:device_event_log_impl.cc(214)] [18:06:08.528] Bluetooth: bluetooth_adapter_winrt.cc:1073 Getting Default Adapter failed.
[10116:7976:1029/180608.527:ERROR:chrome_browser_main_extra_parts_metrics.cc(236)] crbug.com/1216328: Checking default browser status started. Please report if there is no report that this ends.
[10116:7976:1029/180608.561:ERROR:chrome_browser_main_extra_parts_metrics.cc(240)] crbug.com/1216328: Checking default browser status ended.
[10116:10692:1029/180608.589:ERROR:usb_descriptors.cc(114)] Failed to parse configuration descriptor.
[10116:10692:1029/180608.725:ERROR:usb_descriptors.cc(100)] Failed to read all configuration descriptors. Expected 1, got 0.
[10116:10692:1029/180608.725:ERROR:device_event_log_impl.cc(214)] [18:06:08.726] USB: usb_device_win.cc:93 Failed to read descriptors from \\?\usb#vid_0000&pid_3825#5&50adea6&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}.
<bound method WebDriver.quit of <selenium.webdriver.chrome.webdriver.WebDriver (session="9dde593ef8cb9492d05b49ea42fc0d9f")>>

Any idea how to fix such errors?知道如何修复此类错误吗?

To initiate Chrome browser using a proxy you can try the following solution:要使用代理启动 Chrome 浏览器,您可以尝试以下解决方案:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

PROXY = "164.68.123.119:9300"
options = Options()
options.add_argument('--proxy-server={}'.format(PROXY))
options.add_argument("start-maximized")
driver = webdriver.Chrome(executable_path=r'C:\WebDriver\ChromeDriver\chromedriver.exe', options=options)
print(type(driver))
driver.get("https://www.google.com")
myPageTitle=driver.title
print(myPageTitle)
assert "Google" in myPageTitle
time.sleep(10)
driver.quit()

PS: chrome_browser_main_extra_parts_metrics.cc , device_event_log_impl.cc , usb_descriptors.cc , etc are the result of a generic bug due to Chrome/ChromeDriver compatibility which you can ignore as of now. PS: chrome_browser_main_extra_parts_metrics.ccdevice_event_log_impl.ccusb_descriptors.cc等是由于 Chrome/ChromeDriver 兼容性导致的通用错误的结果,您现在可以忽略。 For details check Parametrized tests are flaky due to a timeout in recording expensive metrics on startup .有关详细信息,请检查 参数化测试由于在启动时记录昂贵的指标超时而不稳定


Reference参考

You can find a relevant discussions in:您可以在以下位置找到相关讨论:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 代理认证通过Selenium chromedriver - Python proxy authentication through Selenium chromedriver 使用Python使用Selenium设置chromedriver代理auth - Setting chromedriver proxy auth with Selenium using Python Python Selenium ChromeDriver 代理不工作 - Python Selenium ChromeDriver proxy not working 在python中使用Selenium chromedriver - Using selenium chromedriver with python 无法在 python 中使用带有硒的 Chromedriver 消除音频错误 - Can't silence audio errors using Chromedriver with selenium in python 无法通过 Selenium 和 Python 使用 ChromeDriver 和 Chrome 登录 ebay 帐户 - Unable to signin into ebay account using ChromeDriver and Chrome through Selenium and Python 类型错误:无法通过 Selenium 和 Python 使用 ChromeDriver 调用“模块”对象 - TypeError: 'module' object is not callable using ChromeDriver through Selenium and Python 如何使用 Selenium 和 ChromeDriver 连接代理 - How to connect proxy using Selenium and ChromeDriver chromedriver 不再运行,因此 ChromeDriver 假设 Chrome 使用 Selenium 到 Python 发生崩溃错误 - chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using Selenium through Python SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 84 使用 ChromeDriver 和 Chrome 通过 Selenium 和 Python - SessionNotCreatedException: This version of ChromeDriver only supports Chrome version 84 using ChromeDriver and Chrome through Selenium and Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM