From 38b7a505adda9237e7dde36952b0ee6ae7b059e1 Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 14 Sep 2021 14:26:58 +0800 Subject: [PATCH] =?UTF-8?q?SessionOptions=E5=A2=9E=E5=8A=A0set=5Fheaders()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/config.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DrissionPage/config.py b/DrissionPage/config.py index 06c1f6a..971984b 100644 --- a/DrissionPage/config.py +++ b/DrissionPage/config.py @@ -8,10 +8,11 @@ from configparser import RawConfigParser, NoSectionError, NoOptionError from http.cookiejar import Cookie from pathlib import Path +from typing import Any, Union + from requests.cookies import RequestsCookieJar from selenium import webdriver from selenium.webdriver.chrome.options import Options -from typing import Any, Union class OptionsManager(object): @@ -357,6 +358,14 @@ class SessionOptions(object): """ self._max_redirects = max_redirects + def set_headers(self, headers: dict): + """设置headers参数 \n + :param headers: 参数值 + :return: 返回当前对象 + """ + self._headers = {key.lower(): headers[key] for key in headers} + return self + def set_a_header(self, attr: str, value: str): """设置headers中一个项 \n :param attr: 设置名称