|
@@ -37,10 +37,26 @@ class HtmlChecker(object):
|
37
|
37
|
attribute_name: str,
|
38
|
38
|
attribute_value: str,
|
39
|
39
|
)-> bool:
|
|
40
|
+ """
|
|
41
|
+ Check if elem contains attribute named attribute_name with
|
|
42
|
+ attribute_value : example <a id="ident"> elem contain attribute
|
|
43
|
+ with id as attribute_name and ident as attribute_value.
|
|
44
|
+ Checking is not case_sensitive.
|
|
45
|
+
|
|
46
|
+ :param elem: Tag or String Html Element
|
|
47
|
+ :param attribute_name: Html attribute name
|
|
48
|
+ :param attribute_value: Html attribute value
|
|
49
|
+ :return: True only if Element contain this attribute.
|
|
50
|
+ """
|
40
|
51
|
if isinstance(elem, Tag) and \
|
41
|
|
- attribute_name in elem.attrs and \
|
42
|
|
- attribute_value in elem.attrs[attribute_name]:
|
43
|
|
- return True
|
|
52
|
+ attribute_name in elem.attrs:
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+ values_lower=[value.lower()
|
|
57
|
+ for value
|
|
58
|
+ in elem.get_attribute_list(attribute_name) ]
|
|
59
|
+ return attribute_value.lower() in values_lower
|
44
|
60
|
return False
|
45
|
61
|
|
46
|
62
|
|