我试图简单地打开和关闭一个网站,并使用Python3和Selenium获得它的标题。
我的密码-
from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.techwithtim.net")
print(driver.title)
driver.close()
它成功运行,但在终端中显示了这些错误/警告。
DevTools listening on ws://127.0.0.1:3040/devtools/browser/7d22edc8-0e93-4498-a836-55e560ffc60b
[65744:16912:0614/221655.716:ERROR:device_event_log_impl.cc(214)] [22:16:55.716] Bluetooth: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed.
[65744:16912:0614/221655.772:ERROR:device_event_log_impl.cc(214)] [22:16:55.773] USB: usb_device_handle_win.cc:1058 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
有人能帮忙吗?注意-我已经安装python selenium模块和chromewebdriver。
发布于 2021-06-15 03:37:24
我的问题终于解决了。
添加这些更改修复了问题并删除了这些警告。
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-logging"])
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(options=options , executable_path=PATH)
driver.get("https://www.techwithtim.net")
print(driver.title)
driver.close()
https://stackoverflow.com/questions/67973861
复制相似问题