diff --git a/DrissionPage/driver_element.py b/DrissionPage/driver_element.py index 25a270e..0132512 100644 --- a/DrissionPage/driver_element.py +++ b/DrissionPage/driver_element.py @@ -20,7 +20,7 @@ from .config import OptionsManager class DriverElement(DrissionElement): - '''driver模式的元素对象,包装了一个WebElement对象,并封装了常用功能''' + """driver模式的元素对象,包装了一个WebElement对象,并封装了常用功能""" def __init__(self, ele: WebElement, timeout: float = 10): super().__init__(ele) diff --git a/DrissionPage/mix_page.py b/DrissionPage/mix_page.py index 82962ee..18cb215 100644 --- a/DrissionPage/mix_page.py +++ b/DrissionPage/mix_page.py @@ -131,7 +131,7 @@ class MixPage(Null, SessionPage, DriverPage): return self._response @property - def cookies(self) -> Union[dict, list]: # TODO:统一到一种类型 + def cookies(self) -> Union[dict, list]: """返回cookies,根据模式获取""" if self._mode == 's': return super().cookies @@ -167,7 +167,7 @@ class MixPage(Null, SessionPage, DriverPage): if self._mode == 'd': super(SessionPage, self).get(url=to_url, go_anyway=go_anyway) if self.session_url == self.url: - self._url_available = True if self._response and self._response.status_code == 200 else False + self._url_available = True if self._response and self._response.ok else False else: self._url_available = self.check_page() return self._url_available @@ -191,8 +191,8 @@ class MixPage(Null, SessionPage, DriverPage): # return super(SessionPage, self).ele(loc_or_ele, mode=mode, timeout=timeout, show_errmsg=show_errmsg) return DriverPage.ele(self, loc_or_ele, mode=mode, timeout=timeout, show_errmsg=show_errmsg) - def eles(self, loc_or_str: Union[tuple, str], timeout: float = None, show_errmsg: bool = False) -> List[ - DriverElement]: + def eles(self, loc_or_str: Union[tuple, str], timeout: float = None, show_errmsg: bool = False)\ + -> List[DriverElement]: """查找符合条件的所有元素""" if self._mode == 's': return super().eles(loc_or_str, show_errmsg) diff --git a/DrissionPage/session_page.py b/DrissionPage/session_page.py index ee62175..856fc99 100644 --- a/DrissionPage/session_page.py +++ b/DrissionPage/session_page.py @@ -92,7 +92,7 @@ class SessionPage(object): self._response = self._make_response(to_url, **kwargs) if self._response: self._response.html.encoding = self._response.encoding # 修复requests_html丢失编码方式的bug - self._url_available = True if self._response and self._response.status_code == 200 else False + self._url_available = True if self._response and self._response.ok else False return self._url_available def post(self, url: str, params: dict = None, data: dict = None, go_anyway: bool = False, **kwargs) \ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..447d8e0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +selenium~=3.141.0 +requests-html~=0.10.0 +requests~=2.23.0 +# setuptools~=41.2.0 +tldextract~=2.2.2 \ No newline at end of file diff --git a/setup.py b/setup.py index 2ee2f9c..e7fbe08 100644 --- a/setup.py +++ b/setup.py @@ -3,20 +3,30 @@ from setuptools import setup, find_packages +with open("README.md", "r",encoding='utf-8') as fh: + long_description = fh.read() + setup( name="DrissionPage", - version="1.0.0 Alpha", + version="0.8.0", author="g1879", author_email="g1879@qq.com", - description="page contains selenium and requests.", + description="A module that integrates selenium and requests session, encapsulates common page operations, " + "can achieve seamless switching between the two modes.", + long_description=long_description, license="BSD", keywords="DrissionPage", - url="https://gitee.com/g1879/DrissionPage", + url="https://github.com/g1879/DrissionPage", packages=find_packages(), - long_description="Long descrition is actually short...", + install_requires=[ + "selenium", + "requests-html", + "tldextract", + "requests" + ], classifiers=[ "Development Status :: 1 - Alpha", "Topic :: Utilities", "License :: OSI Approved :: BSD License", ], -) \ No newline at end of file +)