selenium爬虫相关报错解决

原代码和报错信息

#程序代码
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
#修改windows.navigator.webdriver,防机器人识别机制,selenium自动登陆判别机制
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation']) 
drive = webdriver.Chrome(chrome_options=chrome_options)

#报错信息
DeprecationWarning: use options instead of chrome_options
  after removing the cwd from sys.path.
  

解决方案

#本渣英语翻译——百度翻译的更渣,本渣被迫在线营业
>不推荐警告:从系统路径中移除cwd后,使用options取代了 chrome_options

大概意思就是此参数是已经弃用的,
原来的参数chrome_options是被新的参数options替换了;

虽然不影响使用,但是看着一片红就是不爽,修改驱动启动传入的参数即可

#修改后代码
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
#修改windows.navigator.webdriver,防机器人识别机制,selenium自动登陆判别机制
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation']) 
drive = webdriver.Chrome(options=chrome_options)

猜你喜欢

转载自blog.csdn.net/qq_35866846/article/details/107858699