无头浏览器+规避检测
from selenium import webdriver
from time import sleep
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import ChromeOptions
#设置浏览器启动 无可视化
option = Options()
option.add_argument('--headless')
option.add_argument('--disable-gpu')
#如何实现让selenium规避被检测的风险
option.add_experimental_option('excludeSwitches', ['enable-automation'])
web_driver = webdriver.Chrome(options=option)
web_driver.get("https://www.baidu.com")
print(web_driver.title)
sleep(2)
web_driver.quit()