mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
打包前完善
This commit is contained in:
parent
1ad8589b14
commit
1a3bdb20e7
@ -20,7 +20,7 @@ from .config import OptionsManager
|
|||||||
|
|
||||||
|
|
||||||
class DriverElement(DrissionElement):
|
class DriverElement(DrissionElement):
|
||||||
'''driver模式的元素对象,包装了一个WebElement对象,并封装了常用功能'''
|
"""driver模式的元素对象,包装了一个WebElement对象,并封装了常用功能"""
|
||||||
|
|
||||||
def __init__(self, ele: WebElement, timeout: float = 10):
|
def __init__(self, ele: WebElement, timeout: float = 10):
|
||||||
super().__init__(ele)
|
super().__init__(ele)
|
||||||
|
@ -131,7 +131,7 @@ class MixPage(Null, SessionPage, DriverPage):
|
|||||||
return self._response
|
return self._response
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cookies(self) -> Union[dict, list]: # TODO:统一到一种类型
|
def cookies(self) -> Union[dict, list]:
|
||||||
"""返回cookies,根据模式获取"""
|
"""返回cookies,根据模式获取"""
|
||||||
if self._mode == 's':
|
if self._mode == 's':
|
||||||
return super().cookies
|
return super().cookies
|
||||||
@ -167,7 +167,7 @@ class MixPage(Null, SessionPage, DriverPage):
|
|||||||
if self._mode == 'd':
|
if self._mode == 'd':
|
||||||
super(SessionPage, self).get(url=to_url, go_anyway=go_anyway)
|
super(SessionPage, self).get(url=to_url, go_anyway=go_anyway)
|
||||||
if self.session_url == self.url:
|
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:
|
else:
|
||||||
self._url_available = self.check_page()
|
self._url_available = self.check_page()
|
||||||
return self._url_available
|
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 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)
|
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[
|
def eles(self, loc_or_str: Union[tuple, str], timeout: float = None, show_errmsg: bool = False)\
|
||||||
DriverElement]:
|
-> List[DriverElement]:
|
||||||
"""查找符合条件的所有元素"""
|
"""查找符合条件的所有元素"""
|
||||||
if self._mode == 's':
|
if self._mode == 's':
|
||||||
return super().eles(loc_or_str, show_errmsg)
|
return super().eles(loc_or_str, show_errmsg)
|
||||||
|
@ -92,7 +92,7 @@ class SessionPage(object):
|
|||||||
self._response = self._make_response(to_url, **kwargs)
|
self._response = self._make_response(to_url, **kwargs)
|
||||||
if self._response:
|
if self._response:
|
||||||
self._response.html.encoding = self._response.encoding # 修复requests_html丢失编码方式的bug
|
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
|
return self._url_available
|
||||||
|
|
||||||
def post(self, url: str, params: dict = None, data: dict = None, go_anyway: bool = False, **kwargs) \
|
def post(self, url: str, params: dict = None, data: dict = None, go_anyway: bool = False, **kwargs) \
|
||||||
|
5
requirements.txt
Normal file
5
requirements.txt
Normal 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
|
20
setup.py
20
setup.py
@ -3,20 +3,30 @@
|
|||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
with open("README.md", "r",encoding='utf-8') as fh:
|
||||||
|
long_description = fh.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="DrissionPage",
|
name="DrissionPage",
|
||||||
version="1.0.0 Alpha",
|
version="0.8.0",
|
||||||
author="g1879",
|
author="g1879",
|
||||||
author_email="g1879@qq.com",
|
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",
|
license="BSD",
|
||||||
keywords="DrissionPage",
|
keywords="DrissionPage",
|
||||||
url="https://gitee.com/g1879/DrissionPage",
|
url="https://github.com/g1879/DrissionPage",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
long_description="Long descrition is actually short...",
|
install_requires=[
|
||||||
|
"selenium",
|
||||||
|
"requests-html",
|
||||||
|
"tldextract",
|
||||||
|
"requests"
|
||||||
|
],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 1 - Alpha",
|
"Development Status :: 1 - Alpha",
|
||||||
"Topic :: Utilities",
|
"Topic :: Utilities",
|
||||||
"License :: OSI Approved :: BSD License",
|
"License :: OSI Approved :: BSD License",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user