selenium+Headless Chrome实现不弹出浏览器,后台运行

导入selenium.webdriver.chrome.options import Options

增加两个参数即可,“--headless”  “--disable-gpu”


from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from PIL import Image,ImageEnhance
 
 
path = 'C:/dd/chromedriver.exe'  # chromedriver.exe 驱动的路径
 
#打开浏览器
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

# 创建浏览器对象
driver = webdriver.Chrome(executable_path=path, chrome_options=chrome_options)

 

你可能感兴趣的:(Python工具,Pycharm,Python,selenium,chrome,不弹出浏览器,python)