selenium Firefox 日誌重定向
阿新 • • 發佈:2018-12-14
from selenium import webdriver
from utils.user_agent import GetHeaders
from selenium.webdriver.common.proxy import *
class Firefox(object):
def usefirefox(self):
profile = webdriver.FirefoxProfile()
options = webdriver.FirefoxOptions()
# 火狐無頭模式
options.add_argument('--headless')
# 設定日誌等級
options.log.level = "debug"
# 設定請求頭
user_agent = GetHeaders().firefox()
profile.set_preference("general.useragent.override", user_agent)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile, firefox_options=options, log_path='/home/ivy/workspace/log')
return driver