from selenium import webdriver
from selenium.webdriver import ActionChains #动作链对象
import time
from selenium.webdriver.chrome.options import Options #无界面浏览器
from selenium.webdriver import ChromeOptions#规避检测
#实现无界面浏览器
chrome_options=Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
#规避检测:反反爬
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
bro=webdriver.Chrome(executable_path="./chromedriver.exe",chrome_options=chrome_options,options=option)#chrome_options参数就是设置不弹出浏览器窗口
bro.get("https://www.baidu.com")
bro.page_source
selenium设置浏览器无可视化界面
最新推荐文章于 2023-10-29 21:13:59 发布