解决方法:代码中添加:
import time from selenium import webdriver from selenium.webdriver import ActionChains options = webdriver.ChromeOptions() options.add_argument('--disable-blink-features=AutomationControlled') #重点代码:去掉了webdriver痕迹 brow = webdriver.Chrome(chrome_options=options) brow.get(url) print("滑块") action_chains = ActionChains(brow) time.sleep(3) print("h1") slider1 = brow.find_element_by_xpath('//*[@id="nc_1_n1z"]') #定位滑块 action_chains.drag_and_drop_by_offset(slider1, 280, 0).perform() #开始滑块验证
根据情况通过options.add_argument()来添加ua和ip代理或其他的请求头信息