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