打包前完善

This commit is contained in:
g1879 2020-05-22 00:34:50 +08:00
parent 1ad8589b14
commit 1a3bdb20e7
5 changed files with 26 additions and 11 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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) \

5
requirements.txt Normal file
View File

@ -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

View File

@ -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",
],
)
)