from selenium import webdriver
# 导入动作链
from selenium.webdriver import ActionChains
from time import sleep
from urllib.parse import quote
from bs4 import BeautifulSoup
from selenium.webdriver.common.keys import Keys
# 实现无可视化界面
from selenium.webdriver.chrome.options import Options
# 实现规避检测
from selenium.webdriver import ChromeOptions
# 加载selenium需要的驱动 phantomJs:也是selenium中的无头浏览其
driver_path = r'D:\chromedriver2\chromedriver.exe'
out_path = r'D:\固件下载合集\固件\TPLINK' # 是你想指定的路径
# 无可视化界面操作
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
# 实现规避检测
options.add_experimental_option('excludeSwitches', ['enable-automation'])
prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': out_path}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(executable_path=driver_path, options=options)
url = 'https://www.baidu.com'
driver.get(url)
print(driver.page_source)
# 无可视化界面/无头浏览器
selenium 无头浏览器+规避检测
最新推荐文章于 2024-07-20 20:25:01 发布