Python selenium 设置 火狐 谷歌 无头模式


在使用seleinum的时候,如果模拟谷歌或者火狐浏览器,出现一个界面的话太难受了所幸firefox和chrome都有了无头模式,也就是没有界面的浏览器,在内存中执行。

firefox设置:

from selenium import webdriver
 
options = webdriver.FirefoxOptions()
options.add_argument('-headless')
browser = webdriver.Firefox(firefox_options=options)
browser.get('https://www.cnblogs.com/xuchunlin/')

 

chrome设置:

Chrome_options = webdriver.ChromeOptions()
Chrome_options.add_argument('-headless')
drive = webdriver.Chrome(chrome_options=Chrome_options)
drive.get('https://www.cnblogs.com/xuchunlin/')

 


免责声明!

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



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