selenium 无头模式
from selenium import webdriver
from selenium.webdriver.chrome.options import Options # => 引入Chrome的配置
import time
# 配置
ch_options = Options()
ch_options.add_argument("--headless") # => 为Chrome配置无头模式
# 在启动浏览器时加入配置
driver = webdriver.Chrome(chrome_options=ch_options) # => 注意这里的参数
driver.get(‘http://baidu.com‘)
driver.find_element_by_id(‘kw‘).send_keys(‘测试‘)
driver.find_element_by_id(‘su‘).click()
time.sleep(2)
# 只有截图才能看到效果咯
driver.save_screenshot(‘./ch.png‘)
driver.quit() 相关推荐
xiangxiaojun 2020-09-23
letheashura 2020-08-14
王练 2020-07-18
xiangxiaojun 2020-06-25
Feastaw 2020-06-18
云之高水之远 2020-06-14
Reiki 2020-06-12
songerxing 2020-06-11
王练 2020-06-11
tiankele0 2020-06-09
云之高水之远 2020-06-05
tiankele0 2020-07-29
curiousL 2020-07-18
Reiki 2020-08-16