From 98b02f3452413c820d6659735f6a22ef780459ee Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 13 Aug 2021 17:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89page?= =?UTF-8?q?=E7=B1=BB=E5=9C=A8title=E6=97=B6=E4=BC=9A=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/base.py | 10 ++++++---- DrissionPage/driver_element.py | 4 ++-- DrissionPage/driver_page.py | 5 ----- DrissionPage/session_page.py | 5 ----- setup.py | 6 ++---- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/DrissionPage/base.py b/DrissionPage/base.py index 4353cb6..1104e65 100644 --- a/DrissionPage/base.py +++ b/DrissionPage/base.py @@ -225,6 +225,12 @@ class BasePage(BaseParser): self.retry_interval = 2 self._url_available = None + @property + def title(self) -> Union[str, None]: + """返回网页title""" + ele = self('t:title') + return ele.text if ele else None + @property def timeout(self) -> float: """返回查找元素时等待的秒数""" @@ -253,10 +259,6 @@ class BasePage(BaseParser): def url(self): return - @property - def title(self): - return - @property def html(self): return diff --git a/DrissionPage/driver_element.py b/DrissionPage/driver_element.py index a36eee3..76d6457 100644 --- a/DrissionPage/driver_element.py +++ b/DrissionPage/driver_element.py @@ -331,7 +331,7 @@ class DriverElement(DrissionElement): """输入文本或组合键,可用于所有场合 \n :param vals: 文本值或按键组合 :param clear: 输入前是否清空文本框 - :return: 是否输入成功 + :return: None """ if clear: self.clear() @@ -342,7 +342,7 @@ class DriverElement(DrissionElement): """专门用于输入文本框,解决文本框有时输入失效的问题 \n :param txt: 文本值 :param clear: 输入前是否清空文本框 - :return: 是否输入成功 + :return: None """ enter = '\n' if txt.endswith('\n') else None full_txt = txt if clear else f'{self.attr("value")}{txt}' diff --git a/DrissionPage/driver_page.py b/DrissionPage/driver_page.py index b9b02f3..7a7e6e8 100644 --- a/DrissionPage/driver_page.py +++ b/DrissionPage/driver_page.py @@ -51,11 +51,6 @@ class DriverPage(BasePage): else: return self.driver.current_url - @property - def title(self) -> str: - """返回网页title""" - return self.driver.title - @property def html(self) -> str: """返回页面html文本""" diff --git a/DrissionPage/session_page.py b/DrissionPage/session_page.py index f6d0cd1..6a22d5a 100644 --- a/DrissionPage/session_page.py +++ b/DrissionPage/session_page.py @@ -49,11 +49,6 @@ class SessionPage(BasePage): """返回当前访问url""" return self._url - @property - def title(self) -> str: - """返回网页title""" - return self.ele('tag:title').text - @property def html(self) -> str: """返回页面html文本""" diff --git a/setup.py b/setup.py index 05f7080..a2e44c3 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python # -*- coding:utf-8 -*- - from setuptools import setup, find_packages with open("README.md", "r", encoding='utf-8') as fh: @@ -8,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh: setup( name="DrissionPage", - version="1.9.3", + version="1.11.0 beta", author="g1879", author_email="g1879@qq.com", description="A module that integrates selenium and requests session, encapsulates common page operations.", @@ -16,7 +14,7 @@ setup( long_description_content_type="text/markdown", license="BSD", keywords="DrissionPage", - url="https://github.com/g1879/DrissionPage", + url="https://gitee.com/g1879/DrissionPage", include_package_data=True, packages=find_packages(), install_requires=[