python3+selenium3——打开无界面的Chrome浏览器

1、启动浏览器的时候不想看的浏览器运行,那就加载浏览器的静默模式,让它在后台偷偷运行。

option = webdriver.ChromeOptions()
option.add_argument('headless')

2、参考代码:

from selenium import webdriver

option = webdriver.ChromeOptions()
option.add_argument('headless')  # 静默模式
# 打开chrome浏览器
driver = webdriver.Chrome(chrome_options=option)
driver.get("http://www.baidu.com")
print(driver.title)

结果:

 

 

参考原文:https://www.cnblogs.com/yoyoketang/p/8078873.html

posted @ 2020-05-06 11:23  Penny悦  阅读(1000)  评论(0编辑  收藏  举报