Python Selenium Webdriver/Chromedriver(连接的设备无法正常工作...)
Python Selenium Webdriver/Chromedriver (Device attached is not functioning...)
我使用 Selenium 来显示网站。
这是我的代码:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
browser = webdriver.Chrome(executable_path = 'SELE/chromedriver.exe')
browser.get("https://lolprofile.net/")
代码确实运行了,但是网站只出现了一秒钟,然后就出现了这组问题代码:
[15696:7680:1231/111918.721:ERROR:device_event_log_impl.cc(211)] [11:19:18.721] USB:
usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the
system is not functioning. (0x1F)
现在我无法继续编码的下一步。
这不是错误,而是警告,不会影响 运行。
浏览器关闭是因为python垃圾收集器在代码执行完成后关闭 chromedriver
你可以只添加 time.sleep()
,或者让一些用户 input("Enter any key to exit:")
停止代码退出
是的,我添加了以下代码,它在关闭前等待 3 秒...
import time
<< your chrome get code goes here >>
time.sleep(3)
我看到有些人绕过了这个错误消息,但这不是微不足道的。
试试这个...
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.get('https://something.com/login')
driver.maximize_window()
我使用 Selenium 来显示网站。 这是我的代码:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
browser = webdriver.Chrome(executable_path = 'SELE/chromedriver.exe')
browser.get("https://lolprofile.net/")
代码确实运行了,但是网站只出现了一秒钟,然后就出现了这组问题代码:
[15696:7680:1231/111918.721:ERROR:device_event_log_impl.cc(211)] [11:19:18.721] USB:
usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the
system is not functioning. (0x1F)
现在我无法继续编码的下一步。
这不是错误,而是警告,不会影响 运行。
浏览器关闭是因为python垃圾收集器在代码执行完成后关闭 chromedriver
你可以只添加 time.sleep()
,或者让一些用户 input("Enter any key to exit:")
停止代码退出
是的,我添加了以下代码,它在关闭前等待 3 秒...
import time
<< your chrome get code goes here >>
time.sleep(3)
我看到有些人绕过了这个错误消息,但这不是微不足道的。
试试这个...
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.get('https://something.com/login')
driver.maximize_window()