# 优化浏览器的加载项 # options = Options() # options.page_load_strategy = 'normal' # driver = webdriver.Chrome(options=options) # desired_capabilities = DesiredCapabilities.CHROME # desired_capabilities["pageLoadStrategy"] = "eager" # none:当html下载完成之后及返回结束,不等待解析完成; # eager:要等待整个dom树加载完成,即DOMContentLoaded这个事件完成,仅对html的内容进行下载解析 # 使用无头浏览器 # chromeOptions.add_argument('headless') # chromeOptions.add_argument('window-size=1920x1080') # chromeOptions.add_argument("--no-sandbox") # –no-sandbox 非沙盒模式运行 # chromeOptions.add_argument("--disable-dev-shm-usage") # 大量渲染时候写入/tmp而非/dev/shm # path = read_config_yml('readmain')['download_path']['path'] # chrome_prefs = {"download.default_directory": path} # chromeOptions.experimental_options["prefs"] = chrome_prefs # driver = webdriver.Chrome(chrome_options=chromeOptions)
浏览器加载项优化
最新推荐文章于 2023-12-10 00:27:50 发布