mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 07:28:19 +01:00
[parsing] tweak tag regex
This commit is contained in:
parent
dbf350c122
commit
7a67a2028f
|
@ -261,7 +261,7 @@ def matching_tag_regex(tag, attribute, value_regex, escape=True):
|
|||
|
||||
return rf'''(?x)
|
||||
<(?:{tag})
|
||||
(?:\s(?:[^>"']|"[^"]*"|'[^']*')*)?
|
||||
(?:\s(?:[^>"'\\]|"[^"\\]*"|'[^'\\]*')*)?
|
||||
\s{re.escape(attribute)}\s*=\s*(?P<_q>['"])(?-x:{value_regex})(?P=_q)
|
||||
'''
|
||||
|
||||
|
@ -278,7 +278,8 @@ def tags_by_name(cls, tag, html):
|
|||
def matchfunc(tag_str, _attrs):
|
||||
return tag_str == tag
|
||||
|
||||
yield from cls.iter_tags(rf'<\s*{re.escape(tag)}[\s>]', html, matchfunc=matchfunc)
|
||||
tag_regex = rf'''<\s*{re.escape(tag)}(?:\s(?:[^>"'\\]|"[^"\\]*"|'[^'\\]*')*)?>'''
|
||||
yield from cls.iter_tags(tag_regex, html, matchfunc=matchfunc)
|
||||
|
||||
@classmethod
|
||||
def tags_by_attribute(cls, attribute, value, html, *, tag=r'[\w:.-]+', escape_value=True):
|
||||
|
|
Loading…
Reference in New Issue
Block a user