mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
eles筛选增加attr();set.cookies()只支持;分隔cookies;
This commit is contained in:
parent
6624c2651a
commit
40dd6290d1
@ -307,6 +307,18 @@ class ElementsList(list):
|
|||||||
r.append(i)
|
r.append(i)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def attr(self, name, value):
|
||||||
|
"""返回所有拥有某个attribute值的元素
|
||||||
|
:param name: 属性名称
|
||||||
|
:param value: 属性值
|
||||||
|
:return: 筛选结果
|
||||||
|
"""
|
||||||
|
r = ElementsList()
|
||||||
|
for i in self:
|
||||||
|
if i.attr(name) == value:
|
||||||
|
r.append(i)
|
||||||
|
return r
|
||||||
|
|
||||||
def _any_state(self, name, is_not=False):
|
def _any_state(self, name, is_not=False):
|
||||||
"""
|
"""
|
||||||
:param name: 状态名称
|
:param name: 状态名称
|
||||||
|
@ -78,4 +78,6 @@ class ElementsList(list):
|
|||||||
|
|
||||||
def property(self, name: str, value: str) -> List[ChromiumElement]: ...
|
def property(self, name: str, value: str) -> List[ChromiumElement]: ...
|
||||||
|
|
||||||
|
def attr(self, name: str, value: str) -> List[ChromiumElement]: ...
|
||||||
|
|
||||||
def _any_state(self, name: str, is_not: bool = False) -> List[ChromiumElement]: ...
|
def _any_state(self, name: str, is_not: bool = False) -> List[ChromiumElement]: ...
|
||||||
|
@ -213,12 +213,14 @@ def cookies_to_tuple(cookies):
|
|||||||
|
|
||||||
elif isinstance(cookies, str):
|
elif isinstance(cookies, str):
|
||||||
c_dict = {}
|
c_dict = {}
|
||||||
r = match(r'.*?=([^=]+)=', cookies)
|
cookies = cookies.rstrip('; ')
|
||||||
if not r: # 只有一个
|
cookies = cookies.split(';')
|
||||||
cookies = [cookies.rstrip(',;')]
|
# r = match(r'.*?=([^=]+)=', cookies)
|
||||||
else:
|
# if not r: # 只有一个
|
||||||
s = match(r'.*([,;]).*', r.group(1)).group(1)
|
# cookies = [cookies.rstrip(',;')]
|
||||||
cookies = cookies.rstrip(s).split(s)
|
# else:
|
||||||
|
# s = match(r'.*([,;]).*', r.group(1)).group(1)
|
||||||
|
# cookies = cookies.rstrip(s).split(s)
|
||||||
|
|
||||||
for attr in cookies:
|
for attr in cookies:
|
||||||
attr_val = attr.strip().split('=', 1)
|
attr_val = attr.strip().split('=', 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user