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: 设置名称 diff --git a/DrissionPage/configs.ini b/DrissionPage/configs.ini index 21eee64..1185031 100644 --- a/DrissionPage/configs.ini +++ b/DrissionPage/configs.ini @@ -1,19 +1,19 @@ [paths] -chromedriver_path = -tmp_path = +chromedriver_path = D:\python\projects\DrissionPage\DrissionPage\chromedriver.exe +tmp_path = D:\python\projects\DrissionPage\DrissionPage\tmp [chrome_options] debugger_address = -binary_location = +binary_location = d:\python\google chrome\chrome\chrome.exe arguments = ['--no-sandbox', '--disable-gpu', '--ignore-certificate-errors', '--disable-infobars'] extensions = [] experimental_options = {'prefs': {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}, 'plugins.plugins_list': [{'enabled': False, 'name': 'Chrome PDF Viewer'}]}, 'useAutomationExtension': False, 'excludeSwitches': ['enable-automation']} [session_options] headers = { - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "Connection": "keep-alive", - "Accept-Charset": "GB2312,utf-8;q=0.7,*;q=0.7" - } + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8", + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", + "Connection": "keep-alive", + "Accept-Charset": "GB2312,utf-8;q=0.7,*;q=0.7" + } diff --git a/setup.py b/setup.py index a2e44c3..c64fa4d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh: setup( name="DrissionPage", - version="1.11.0 beta", + version="1.11.0", author="g1879", author_email="g1879@qq.com", description="A module that integrates selenium and requests session, encapsulates common page operations.",