Browse Source

crawler: improve html iter code

Ignores tags without attributes. Avoids bug with unclosed tags.
master
pictuga 3 months ago
parent
commit
e1ed33f320
  1. 2
      morss/crawler.py

2
morss/crawler.py

@ -368,7 +368,7 @@ class BrowserlyHeaderHandler(BaseHandler):
def iter_html_tag(html_str, tag_name):
" To avoid parsing whole pages when looking for a simple tag "
re_tag = r'<%s(\s*[^>])*>' % tag_name
re_tag = r'<%s\s+[^>]+>' % tag_name
re_attr = r'(?P<key>[^=\s]+)=[\'"](?P<value>[^\'"]+)[\'"]'
for tag_match in re.finditer(re_tag, html_str):

Loading…
Cancel
Save