20 lines
509 B
Python
20 lines
509 B
Python
#-*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2023/12/6 21:31
|
|
@Usage : 无头模式
|
|
@Desc : 之前的案例运行时,总会弹出一个路浏览器窗口
|
|
现在已经支持无头模式Headless
|
|
'''
|
|
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver import ChromeOptions
|
|
|
|
option = ChromeOptions()
|
|
option.add_argument('--headless')
|
|
browser = webdriver.Chrome(options=option)
|
|
browser.set_window_size(1366, 768)
|
|
browser.get('https://www.baidu.com')
|
|
browser.get_screenshot_as_file('preview.png') |