From c3b58bc90d9b1639e6b54a367e9a0ffb7d27a586 Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 8 Jan 2024 18:04:59 +0800 Subject: [PATCH] =?UTF-8?q?4.0.0get=5Fframe()=E5=BA=8F=E5=8F=B7=E6=94=B9?= =?UTF-8?q?=E6=88=90=E4=BB=8E0=E5=BC=80=E5=A7=8B=EF=BC=9B=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2save()=E5=A2=9E=E5=8A=A0as=5Fpdf=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E5=B0=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 9 +++-- DrissionPage/_base/base.py | 6 ++- DrissionPage/_base/base.pyi | 6 ++- DrissionPage/_base/browser.py | 17 +++++--- DrissionPage/_base/browser.pyi | 6 ++- DrissionPage/_base/driver.py | 6 ++- DrissionPage/_base/driver.pyi | 6 ++- DrissionPage/_configs/chromium_options.py | 6 ++- DrissionPage/_configs/chromium_options.pyi | 6 ++- DrissionPage/_configs/options_manage.py | 6 ++- DrissionPage/_configs/options_manage.pyi | 6 ++- DrissionPage/_configs/session_options.py | 6 ++- DrissionPage/_configs/session_options.pyi | 6 ++- DrissionPage/_elements/chromium_element.py | 6 ++- DrissionPage/_elements/chromium_element.pyi | 6 ++- DrissionPage/_elements/none_element.py | 6 ++- DrissionPage/_elements/session_element.py | 6 ++- DrissionPage/_elements/session_element.pyi | 6 ++- DrissionPage/_functions/browser.py | 6 ++- DrissionPage/_functions/browser.pyi | 6 ++- DrissionPage/_functions/by.py | 8 ++++ DrissionPage/_functions/cli.py | 6 ++- DrissionPage/_functions/keys.py | 6 ++- DrissionPage/_functions/keys.pyi | 6 ++- DrissionPage/_functions/locator.py | 6 ++- DrissionPage/_functions/locator.pyi | 6 ++- DrissionPage/_functions/settings.py | 6 ++- DrissionPage/_functions/tools.py | 6 ++- DrissionPage/_functions/tools.pyi | 6 ++- DrissionPage/_functions/web.py | 6 ++- DrissionPage/_functions/web.pyi | 6 ++- DrissionPage/_pages/chromium_base.py | 45 +++++++++++++++++---- DrissionPage/_pages/chromium_base.pyi | 15 +++++-- DrissionPage/_pages/chromium_frame.py | 6 ++- DrissionPage/_pages/chromium_frame.pyi | 6 ++- DrissionPage/_pages/chromium_page.py | 18 +++++---- DrissionPage/_pages/chromium_page.pyi | 27 +++++++++++-- DrissionPage/_pages/chromium_tab.py | 6 ++- DrissionPage/_pages/chromium_tab.pyi | 6 ++- DrissionPage/_pages/session_page.py | 6 ++- DrissionPage/_pages/session_page.pyi | 6 ++- DrissionPage/_pages/web_page.py | 6 ++- DrissionPage/_pages/web_page.pyi | 6 ++- DrissionPage/_units/actions.py | 6 ++- DrissionPage/_units/actions.pyi | 6 ++- DrissionPage/_units/clicker.py | 6 ++- DrissionPage/_units/clicker.pyi | 6 ++- DrissionPage/_units/cookies_setter.py | 6 ++- DrissionPage/_units/cookies_setter.pyi | 6 +++ DrissionPage/_units/downloader.py | 6 ++- DrissionPage/_units/downloader.pyi | 6 ++- DrissionPage/_units/listener.py | 6 ++- DrissionPage/_units/listener.pyi | 6 ++- DrissionPage/_units/rect.py | 6 ++- DrissionPage/_units/rect.pyi | 6 ++- DrissionPage/_units/screencast.py | 6 ++- DrissionPage/_units/screencast.pyi | 6 ++- DrissionPage/_units/scroller.py | 6 ++- DrissionPage/_units/scroller.pyi | 6 +++ DrissionPage/_units/selector.py | 6 ++- DrissionPage/_units/selector.pyi | 6 ++- DrissionPage/_units/setter.py | 6 ++- DrissionPage/_units/setter.pyi | 6 ++- DrissionPage/_units/states.py | 6 ++- DrissionPage/_units/states.pyi | 6 ++- DrissionPage/_units/waiter.py | 6 +++ DrissionPage/_units/waiter.pyi | 6 ++- DrissionPage/common.py | 6 ++- DrissionPage/errors.py | 6 ++- README.md | 4 +- requirements.txt | 2 +- setup.py | 4 +- 72 files changed, 369 insertions(+), 152 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index 5220f8d..5eb95ff 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -1,9 +1,10 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ -# 常用页面类 from ._pages.chromium_page import ChromiumPage from ._pages.session_page import SessionPage from ._pages.web_page import WebPage @@ -13,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions from ._configs.session_options import SessionOptions __all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__'] -__version__ = '4.0.0b35' +__version__ = '4.0.0' diff --git a/DrissionPage/_base/base.py b/DrissionPage/_base/base.py index 8f2598d..0f16588 100644 --- a/DrissionPage/_base/base.py +++ b/DrissionPage/_base/base.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from abc import abstractmethod from re import sub diff --git a/DrissionPage/_base/base.pyi b/DrissionPage/_base/base.pyi index 13175e1..b4964b0 100644 --- a/DrissionPage/_base/base.pyi +++ b/DrissionPage/_base/base.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from abc import abstractmethod from typing import Union, Tuple, List, Any diff --git a/DrissionPage/_base/browser.py b/DrissionPage/_base/browser.py index 7d2e61f..0e71e1d 100644 --- a/DrissionPage/_base/browser.py +++ b/DrissionPage/_base/browser.py @@ -1,12 +1,16 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from shutil import rmtree from time import sleep, perf_counter +from websocket import WebSocketBadStatusException + from .driver import BrowserDriver, Driver from .._functions.tools import stop_process_on_port, raise_error from .._units.downloader import DownloadManager @@ -70,8 +74,11 @@ class Browser(object): """标签页创建时执行""" if (kwargs['targetInfo']['type'] in ('page', 'webview') and not kwargs['targetInfo']['url'].startswith('devtools://')): - self._drivers[kwargs['targetInfo']['targetId']] = Driver(kwargs['targetInfo']['targetId'], - 'page', self.address) + try: + self._drivers[kwargs['targetInfo']['targetId']] = Driver(kwargs['targetInfo']['targetId'], + 'page', self.address) + except WebSocketBadStatusException: + pass def _onTargetDestroyed(self, **kwargs): """标签页关闭时执行""" @@ -205,5 +212,5 @@ class Browser(object): try: rmtree(path) break - except (PermissionError, FileNotFoundError): + except (PermissionError, FileNotFoundError, OSError): pass diff --git a/DrissionPage/_base/browser.pyi b/DrissionPage/_base/browser.pyi index b5d0161..e29afcb 100644 --- a/DrissionPage/_base/browser.pyi +++ b/DrissionPage/_base/browser.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import List, Optional, Union diff --git a/DrissionPage/_base/driver.py b/DrissionPage/_base/driver.py index 809c747..d5ce858 100644 --- a/DrissionPage/_base/driver.py +++ b/DrissionPage/_base/driver.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from json import dumps, loads, JSONDecodeError from queue import Queue, Empty diff --git a/DrissionPage/_base/driver.pyi b/DrissionPage/_base/driver.pyi index cdabcb2..ae86582 100644 --- a/DrissionPage/_base/driver.pyi +++ b/DrissionPage/_base/driver.pyi @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from queue import Queue from threading import Thread, Event diff --git a/DrissionPage/_configs/chromium_options.py b/DrissionPage/_configs/chromium_options.py index 342008e..11b56f2 100644 --- a/DrissionPage/_configs/chromium_options.py +++ b/DrissionPage/_configs/chromium_options.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from re import search diff --git a/DrissionPage/_configs/chromium_options.pyi b/DrissionPage/_configs/chromium_options.pyi index 8fd4ab9..ce2a748 100644 --- a/DrissionPage/_configs/chromium_options.pyi +++ b/DrissionPage/_configs/chromium_options.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from threading import Lock diff --git a/DrissionPage/_configs/options_manage.py b/DrissionPage/_configs/options_manage.py index a524c08..703adbd 100644 --- a/DrissionPage/_configs/options_manage.py +++ b/DrissionPage/_configs/options_manage.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from configparser import RawConfigParser, NoSectionError, NoOptionError from pathlib import Path diff --git a/DrissionPage/_configs/options_manage.pyi b/DrissionPage/_configs/options_manage.pyi index bd431f5..805ae92 100644 --- a/DrissionPage/_configs/options_manage.pyi +++ b/DrissionPage/_configs/options_manage.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from configparser import RawConfigParser from typing import Any diff --git a/DrissionPage/_configs/session_options.py b/DrissionPage/_configs/session_options.py index f68d6b0..532098a 100644 --- a/DrissionPage/_configs/session_options.py +++ b/DrissionPage/_configs/session_options.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path diff --git a/DrissionPage/_configs/session_options.pyi b/DrissionPage/_configs/session_options.pyi index cbd2931..cc1b4e9 100644 --- a/DrissionPage/_configs/session_options.pyi +++ b/DrissionPage/_configs/session_options.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Any, Union, Tuple, Optional diff --git a/DrissionPage/_elements/chromium_element.py b/DrissionPage/_elements/chromium_element.py index 8045070..9dff0a2 100644 --- a/DrissionPage/_elements/chromium_element.py +++ b/DrissionPage/_elements/chromium_element.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from os.path import basename, sep from pathlib import Path diff --git a/DrissionPage/_elements/chromium_element.pyi b/DrissionPage/_elements/chromium_element.pyi index 9eab619..fa341ca 100644 --- a/DrissionPage/_elements/chromium_element.pyi +++ b/DrissionPage/_elements/chromium_element.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, List, Any, Literal diff --git a/DrissionPage/_elements/none_element.py b/DrissionPage/_elements/none_element.py index 25732e5..fac5415 100644 --- a/DrissionPage/_elements/none_element.py +++ b/DrissionPage/_elements/none_element.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from ..errors import ElementNotFoundError diff --git a/DrissionPage/_elements/session_element.py b/DrissionPage/_elements/session_element.py index 82820a9..c829ed6 100644 --- a/DrissionPage/_elements/session_element.py +++ b/DrissionPage/_elements/session_element.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from html import unescape from re import match, sub, DOTALL diff --git a/DrissionPage/_elements/session_element.pyi b/DrissionPage/_elements/session_element.pyi index 32452c6..5c82e6f 100644 --- a/DrissionPage/_elements/session_element.pyi +++ b/DrissionPage/_elements/session_element.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, List, Tuple, Optional diff --git a/DrissionPage/_functions/browser.py b/DrissionPage/_functions/browser.py index dfa3b3e..113a7f9 100644 --- a/DrissionPage/_functions/browser.py +++ b/DrissionPage/_functions/browser.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from json import load, dump, JSONDecodeError from os import popen diff --git a/DrissionPage/_functions/browser.pyi b/DrissionPage/_functions/browser.pyi index a1e6fa9..6285a34 100644 --- a/DrissionPage/_functions/browser.pyi +++ b/DrissionPage/_functions/browser.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union diff --git a/DrissionPage/_functions/by.py b/DrissionPage/_functions/by.py index 899a183..e494189 100644 --- a/DrissionPage/_functions/by.py +++ b/DrissionPage/_functions/by.py @@ -1,4 +1,12 @@ # -*- coding:utf-8 -*- +""" +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. +""" + + class By: ID = 'id' XPATH = 'xpath' diff --git a/DrissionPage/_functions/cli.py b/DrissionPage/_functions/cli.py index a06b228..0141c60 100644 --- a/DrissionPage/_functions/cli.py +++ b/DrissionPage/_functions/cli.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from click import command, option diff --git a/DrissionPage/_functions/keys.py b/DrissionPage/_functions/keys.py index 8c0a243..e4bebea 100644 --- a/DrissionPage/_functions/keys.py +++ b/DrissionPage/_functions/keys.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from ..errors import AlertExistsError diff --git a/DrissionPage/_functions/keys.pyi b/DrissionPage/_functions/keys.pyi index de2ca51..896bc42 100644 --- a/DrissionPage/_functions/keys.pyi +++ b/DrissionPage/_functions/keys.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Tuple, Dict, Union, Any diff --git a/DrissionPage/_functions/locator.py b/DrissionPage/_functions/locator.py index 13ee7d1..ac65759 100644 --- a/DrissionPage/_functions/locator.py +++ b/DrissionPage/_functions/locator.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from re import split from .by import By diff --git a/DrissionPage/_functions/locator.pyi b/DrissionPage/_functions/locator.pyi index b890c03..2f79a69 100644 --- a/DrissionPage/_functions/locator.pyi +++ b/DrissionPage/_functions/locator.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union diff --git a/DrissionPage/_functions/settings.py b/DrissionPage/_functions/settings.py index 0107271..225190c 100644 --- a/DrissionPage/_functions/settings.py +++ b/DrissionPage/_functions/settings.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ diff --git a/DrissionPage/_functions/tools.py b/DrissionPage/_functions/tools.py index 723327a..b785ed1 100644 --- a/DrissionPage/_functions/tools.py +++ b/DrissionPage/_functions/tools.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from platform import system diff --git a/DrissionPage/_functions/tools.pyi b/DrissionPage/_functions/tools.pyi index 2e3aa73..057a43f 100644 --- a/DrissionPage/_functions/tools.pyi +++ b/DrissionPage/_functions/tools.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from os import popen from pathlib import Path diff --git a/DrissionPage/_functions/web.py b/DrissionPage/_functions/web.py index 4e4cee7..9479c05 100644 --- a/DrissionPage/_functions/web.py +++ b/DrissionPage/_functions/web.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from datetime import datetime from html import unescape diff --git a/DrissionPage/_functions/web.pyi b/DrissionPage/_functions/web.pyi index 128f48f..240bdab 100644 --- a/DrissionPage/_functions/web.pyi +++ b/DrissionPage/_functions/web.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from http.cookiejar import Cookie from typing import Union diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 7088998..dbaf4f8 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from json import loads, JSONDecodeError from os.path import sep @@ -651,7 +653,7 @@ class ChromiumBase(BasePage): self.run_cdp('DOM.removeNode', nodeId=ele._node_id) def get_frame(self, loc_ind_ele, timeout=None): - """获取页面中一个frame对象,可传入定位符、iframe序号、ChromiumFrame对象,序号从1开始 + """获取页面中一个frame对象,可传入定位符、iframe序号、ChromiumFrame对象,序号从0开始 :param loc_ind_ele: 定位符、iframe序号、ChromiumFrame对象 :param timeout: 查找元素超时时间(秒) :return: ChromiumFrame对象 @@ -674,9 +676,9 @@ class ChromiumBase(BasePage): r = ele elif isinstance(loc_ind_ele, int): - if loc_ind_ele < 1: - raise ValueError('序号必须大于0。') - xpath = f'xpath:(//*[name()="frame" or name()="iframe"])[{loc_ind_ele}]' + if loc_ind_ele < 0: + raise ValueError('序号必须大于等于0。') + xpath = f'xpath:(//*[name()="frame" or name()="iframe"])[{loc_ind_ele + 1}]' r = self._ele(xpath, timeout=timeout) elif str(type(loc_ind_ele)).endswith(".ChromiumFrame'>"): @@ -1135,7 +1137,7 @@ def get_mhtml(page, path=None, name=None): """把当前页面保存为mhtml文件,如果path和name参数都为None,只返回mhtml文本 :param page: 要保存的页面对象 :param path: 保存路径,为None且name不为None时保存在当前路径 - :param name: 文件名,为None且path不为None时用title属性值 + :param name: 文件名,为None且path不为None时用title属性值 :return: mhtml文本 """ r = page.run_cdp('Page.captureSnapshot')['data'] @@ -1147,3 +1149,32 @@ def get_mhtml(page, path=None, name=None): with open(f'{path}{sep}{name}.mhtml', 'w', encoding='utf-8') as f: f.write(r) return r + + +def get_pdf(page, path=None, name=None, kwargs=None): + """把当前页面保存为pdf文件,如果path和name参数都为None,只返回字节 + :param page: 要保存的页面对象 + :param path: 保存路径,为None且name不为None时保存在当前路径 + :param name: 文件名,为None且path不为None时用title属性值 + :param kwargs: pdf生成参数 + :return: pdf文本 + """ + if not kwargs: + kwargs = {} + kwargs['transferMode'] = 'ReturnAsBase64' + if 'printBackground' not in kwargs: + kwargs['printBackground'] = True + try: + r = page.run_cdp('Page.printToPDF', **kwargs)['data'] + except: + raise RuntimeError('保存失败,可能浏览器版本不支持。') + from base64 import b64decode + r = b64decode(r) + if path is None and name is None: + return r + path = path or '.' + Path(path).mkdir(parents=True, exist_ok=True) + name = make_valid_name(name or page.title) + with open(f'{path}{sep}{name}.pdf', 'wb') as f: + f.write(r) + return r diff --git a/DrissionPage/_pages/chromium_base.pyi b/DrissionPage/_pages/chromium_base.pyi index a24ddd8..d4993b1 100644 --- a/DrissionPage/_pages/chromium_base.pyi +++ b/DrissionPage/_pages/chromium_base.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, List, Any, Optional, Literal @@ -270,4 +272,11 @@ class Alert(object): self.auto: Optional[bool] = ... -def get_mhtml(page: Union[ChromiumPage, ChromiumTab], path: Union[str, Path] = None, name: str = None) -> str: ... +def get_mhtml(page: Union[ChromiumPage, ChromiumTab], + path: Union[str, Path] = None, + name: str = None) -> str: ... + + +def get_pdf(page: Union[ChromiumPage, ChromiumTab], + path: Union[str, Path] = None, + name: str = None, kwargs: dict=None) -> bytes: ... diff --git a/DrissionPage/_pages/chromium_frame.py b/DrissionPage/_pages/chromium_frame.py index 290b9a5..a7aac92 100644 --- a/DrissionPage/_pages/chromium_frame.py +++ b/DrissionPage/_pages/chromium_frame.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from copy import copy from re import search, findall, DOTALL diff --git a/DrissionPage/_pages/chromium_frame.pyi b/DrissionPage/_pages/chromium_frame.pyi index a2149bb..74c3314 100644 --- a/DrissionPage/_pages/chromium_frame.pyi +++ b/DrissionPage/_pages/chromium_frame.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, List, Any diff --git a/DrissionPage/_pages/chromium_page.py b/DrissionPage/_pages/chromium_page.py index c4a0a93..820d085 100644 --- a/DrissionPage/_pages/chromium_page.py +++ b/DrissionPage/_pages/chromium_page.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from time import sleep, perf_counter @@ -11,7 +13,7 @@ from requests import get from .._base.browser import Browser from .._functions.browser import connect_browser from .._configs.chromium_options import ChromiumOptions, PortFinder -from .._pages.chromium_base import ChromiumBase, get_mhtml, Timeout +from .._pages.chromium_base import ChromiumBase, get_mhtml, get_pdf, Timeout from .._pages.chromium_tab import ChromiumTab from .._units.setter import ChromiumPageSetter from .._units.waiter import PageWaiter @@ -146,13 +148,15 @@ class ChromiumPage(ChromiumBase): """返回浏览器进程id""" return self.browser.process_id - def save(self, path=None, name=None): - """把当前页面保存为mhtml文件,如果path和name参数都为None,只返回mhtml文本 + def save(self, path=None, name=None, as_pdf=False, **kwargs): + """把当前页面保存为文件,如果path和name参数都为None,只返回文本 :param path: 保存路径,为None且name不为None时保存在当前路径 :param name: 文件名,为None且path不为None时用title属性值 - :return: mhtml文本 + :param as_pdf: 为Ture保存为pdf,否则为mhtml且忽略kwargs参数 + :param kwargs: pdf生成参数 + :return: as_pdf为True时返回bytes,否则返回文件文本 """ - return get_mhtml(self, path, name) + return get_pdf(self, path, name, kwargs)if as_pdf else get_mhtml(self, path, name) def get_tab(self, id_or_num=None): """获取一个标签页对象 diff --git a/DrissionPage/_pages/chromium_page.pyi b/DrissionPage/_pages/chromium_page.pyi index 6617fde..407cd1a 100644 --- a/DrissionPage/_pages/chromium_page.pyi +++ b/DrissionPage/_pages/chromium_page.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, List, Optional @@ -55,7 +57,26 @@ class ChromiumPage(ChromiumBase): @property def set(self) -> ChromiumPageSetter: ... - def save(self, path: Union[str, Path] = None, name: str = None) -> str: ... + def save(self, + path: Union[str, Path] = None, + name: str = None, + as_pdf: bool = False, + landscape: bool = ..., + displayHeaderFooter: bool = ..., + printBackground: bool = ..., + scale: float = ..., + paperWidth: float = ..., + paperHeight: float = ..., + marginTop: float = ..., + marginBottom: float = ..., + marginLeft: float = ..., + marginRight: float = ..., + pageRanges: str = ..., + headerTemplate: str = ..., + footerTemplate: str = ..., + preferCSSPageSize: bool = ..., + generateTaggedPDF: bool = ..., + generateDocumentOutline: bool = ...) -> Union[bytes, str]: ... def get_tab(self, tab_id: Union[str, ChromiumTab, int] = None) -> ChromiumTab: ... diff --git a/DrissionPage/_pages/chromium_tab.py b/DrissionPage/_pages/chromium_tab.py index 06ae0fa..9eaf97e 100644 --- a/DrissionPage/_pages/chromium_tab.py +++ b/DrissionPage/_pages/chromium_tab.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from copy import copy diff --git a/DrissionPage/_pages/chromium_tab.pyi b/DrissionPage/_pages/chromium_tab.pyi index f80d0a6..7735312 100644 --- a/DrissionPage/_pages/chromium_tab.pyi +++ b/DrissionPage/_pages/chromium_tab.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, Any, List, Optional diff --git a/DrissionPage/_pages/session_page.py b/DrissionPage/_pages/session_page.py index 0f3ddce..4faa2c3 100644 --- a/DrissionPage/_pages/session_page.py +++ b/DrissionPage/_pages/session_page.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from re import search, DOTALL diff --git a/DrissionPage/_pages/session_page.pyi b/DrissionPage/_pages/session_page.pyi index dd4da4e..a6379ca 100644 --- a/DrissionPage/_pages/session_page.pyi +++ b/DrissionPage/_pages/session_page.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Any, Union, Tuple, List, Optional diff --git a/DrissionPage/_pages/web_page.py b/DrissionPage/_pages/web_page.py index 7fec00d..fd4e079 100644 --- a/DrissionPage/_pages/web_page.py +++ b/DrissionPage/_pages/web_page.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from .chromium_page import ChromiumPage from .chromium_tab import WebPageTab diff --git a/DrissionPage/_pages/web_page.pyi b/DrissionPage/_pages/web_page.pyi index 2b1671d..20bcdf0 100644 --- a/DrissionPage/_pages/web_page.pyi +++ b/DrissionPage/_pages/web_page.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, Tuple, List, Any diff --git a/DrissionPage/_units/actions.py b/DrissionPage/_units/actions.py index 7f47b11..0a41be9 100644 --- a/DrissionPage/_units/actions.py +++ b/DrissionPage/_units/actions.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from time import sleep, perf_counter diff --git a/DrissionPage/_units/actions.pyi b/DrissionPage/_units/actions.pyi index 8a56363..55f863c 100644 --- a/DrissionPage/_units/actions.pyi +++ b/DrissionPage/_units/actions.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, Tuple, Any, Literal diff --git a/DrissionPage/_units/clicker.py b/DrissionPage/_units/clicker.py index 6565e50..1c397ac 100644 --- a/DrissionPage/_units/clicker.py +++ b/DrissionPage/_units/clicker.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from time import perf_counter, sleep diff --git a/DrissionPage/_units/clicker.pyi b/DrissionPage/_units/clicker.pyi index 34286a9..895f762 100644 --- a/DrissionPage/_units/clicker.pyi +++ b/DrissionPage/_units/clicker.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, Optional diff --git a/DrissionPage/_units/cookies_setter.py b/DrissionPage/_units/cookies_setter.py index 3eda66a..63bcc2f 100644 --- a/DrissionPage/_units/cookies_setter.py +++ b/DrissionPage/_units/cookies_setter.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from http.cookiejar import Cookie diff --git a/DrissionPage/_units/cookies_setter.pyi b/DrissionPage/_units/cookies_setter.pyi index f1b5877..3c6f37a 100644 --- a/DrissionPage/_units/cookies_setter.pyi +++ b/DrissionPage/_units/cookies_setter.pyi @@ -1,4 +1,10 @@ # -*- coding:utf-8 -*- +""" +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. +""" from http.cookiejar import Cookie from typing import Union diff --git a/DrissionPage/_units/downloader.py b/DrissionPage/_units/downloader.py index 9d84e8b..2d0cdb4 100644 --- a/DrissionPage/_units/downloader.py +++ b/DrissionPage/_units/downloader.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from os.path import sep from pathlib import Path diff --git a/DrissionPage/_units/downloader.pyi b/DrissionPage/_units/downloader.pyi index 1617d56..37d8ae7 100644 --- a/DrissionPage/_units/downloader.pyi +++ b/DrissionPage/_units/downloader.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Dict, Optional, Union, Literal diff --git a/DrissionPage/_units/listener.py b/DrissionPage/_units/listener.py index 343a066..9063b53 100644 --- a/DrissionPage/_units/listener.py +++ b/DrissionPage/_units/listener.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from base64 import b64decode from json import JSONDecodeError, loads diff --git a/DrissionPage/_units/listener.pyi b/DrissionPage/_units/listener.pyi index b2511df..9daef5d 100644 --- a/DrissionPage/_units/listener.pyi +++ b/DrissionPage/_units/listener.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from queue import Queue from typing import Union, Dict, List, Iterable, Optional, Literal diff --git a/DrissionPage/_units/rect.py b/DrissionPage/_units/rect.py index ac1a8a9..3011ec6 100644 --- a/DrissionPage/_units/rect.py +++ b/DrissionPage/_units/rect.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ diff --git a/DrissionPage/_units/rect.pyi b/DrissionPage/_units/rect.pyi index deb346f..2e442ce 100644 --- a/DrissionPage/_units/rect.pyi +++ b/DrissionPage/_units/rect.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Tuple, Union, List diff --git a/DrissionPage/_units/screencast.py b/DrissionPage/_units/screencast.py index b752f27..958dbfc 100644 --- a/DrissionPage/_units/screencast.py +++ b/DrissionPage/_units/screencast.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from base64 import b64decode from os.path import sep diff --git a/DrissionPage/_units/screencast.pyi b/DrissionPage/_units/screencast.pyi index c185375..92d7d0f 100644 --- a/DrissionPage/_units/screencast.pyi +++ b/DrissionPage/_units/screencast.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union diff --git a/DrissionPage/_units/scroller.py b/DrissionPage/_units/scroller.py index b1b987e..545b3f7 100644 --- a/DrissionPage/_units/scroller.py +++ b/DrissionPage/_units/scroller.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from time import sleep, perf_counter diff --git a/DrissionPage/_units/scroller.pyi b/DrissionPage/_units/scroller.pyi index 510543d..8233948 100644 --- a/DrissionPage/_units/scroller.pyi +++ b/DrissionPage/_units/scroller.pyi @@ -1,4 +1,10 @@ # -*- coding:utf-8 -*- +""" +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. +""" from typing import Union from .._elements.chromium_element import ChromiumElement diff --git a/DrissionPage/_units/selector.py b/DrissionPage/_units/selector.py index e7a84d3..1b94ed7 100644 --- a/DrissionPage/_units/selector.py +++ b/DrissionPage/_units/selector.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from time import perf_counter diff --git a/DrissionPage/_units/selector.pyi b/DrissionPage/_units/selector.pyi index f0d2fcc..8e74554 100644 --- a/DrissionPage/_units/selector.pyi +++ b/DrissionPage/_units/selector.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, Tuple, List diff --git a/DrissionPage/_units/setter.py b/DrissionPage/_units/setter.py index f6d0f87..7928a93 100644 --- a/DrissionPage/_units/setter.py +++ b/DrissionPage/_units/setter.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path diff --git a/DrissionPage/_units/setter.pyi b/DrissionPage/_units/setter.pyi index c68d848..a5ece0b 100644 --- a/DrissionPage/_units/setter.pyi +++ b/DrissionPage/_units/setter.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from pathlib import Path from typing import Union, Tuple, Literal, Any, Optional diff --git a/DrissionPage/_units/states.py b/DrissionPage/_units/states.py index 9736a33..bdf99cc 100644 --- a/DrissionPage/_units/states.py +++ b/DrissionPage/_units/states.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from .._functions.web import location_in_viewport from ..errors import CDPError, NoRectError, PageDisconnectedError, ElementLostError diff --git a/DrissionPage/_units/states.pyi b/DrissionPage/_units/states.pyi index dcd57e5..067c0bd 100644 --- a/DrissionPage/_units/states.pyi +++ b/DrissionPage/_units/states.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union, Tuple, List, Optional, Literal diff --git a/DrissionPage/_units/waiter.py b/DrissionPage/_units/waiter.py index 84a6676..1569b0e 100644 --- a/DrissionPage/_units/waiter.py +++ b/DrissionPage/_units/waiter.py @@ -1,4 +1,10 @@ # -*- coding:utf-8 -*- +""" +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. +""" from time import sleep, perf_counter from .._functions.settings import Settings diff --git a/DrissionPage/_units/waiter.pyi b/DrissionPage/_units/waiter.pyi index 9e0ada1..a0c8603 100644 --- a/DrissionPage/_units/waiter.pyi +++ b/DrissionPage/_units/waiter.pyi @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from typing import Union diff --git a/DrissionPage/common.py b/DrissionPage/common.py index 44ab030..df2b6aa 100644 --- a/DrissionPage/common.py +++ b/DrissionPage/common.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ from ._elements.session_element import make_session_ele from ._functions.by import By diff --git a/DrissionPage/errors.py b/DrissionPage/errors.py index 155453e..9ed94df 100644 --- a/DrissionPage/errors.py +++ b/DrissionPage/errors.py @@ -1,7 +1,9 @@ # -*- coding:utf-8 -*- """ -@Author : g1879 -@Contact : g1879@qq.com +@Author : g1879 +@Contact : g1879@qq.com +@Copyright: (c) 2024 by g1879, Inc. All Rights Reserved. +@License : BSD 3-Clause. """ diff --git a/README.md b/README.md index d775971..9dfc9ec 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ DrissionPage 是一个基于 python 的网页自动化工具。 支持系统:Windows、Linux、Mac -python 版本:3.6 及以上 +python 版本:3.8 及以上 支持浏览器:Chromium 内核浏览器(如 Chrome 和 Edge),electron 应用 @@ -108,7 +108,7 @@ python 版本:3.6 及以上 # 🔖 版本历史 -[点击查看版本历史](https://g1879.gitee.io/drissionpagedocs/history/) +[点击查看版本历史](https://g1879.gitee.io/drissionpagedocs/history/introduction/) --- diff --git a/requirements.txt b/requirements.txt index 8d24602..8a430e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ requests lxml cssselect -DownloadKit>=2.0.0b5 +DownloadKit>=2.0.0 websocket-client>=1.7.0 click tldextract diff --git a/setup.py b/setup.py index 8f5dd8f..4cfbfa7 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="4.0.0b35", + version="4.0.0", author="g1879", author_email="g1879@qq.com", description="Python based web automation tool. It can control the browser and send and receive data packets.", @@ -22,7 +22,7 @@ setup( 'lxml', 'requests', 'cssselect', - 'DownloadKit>=2.0.0b5', + 'DownloadKit>=2.0.0', 'websocket-client>=1.7.0', 'click', 'tldextract',