无论是火狐还是谷歌浏览器只需要添加一个参数即可:
from selenium.webdriver.firefox.options import Options Options().add_argument('--headless')