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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM