Handle newlines in title HTML.

This commit is contained in:
Edward Betts 2023-09-11 07:40:16 +01:00
parent 2f4f1481c7
commit 52dfe9e42c

View file

@ -9,7 +9,7 @@ from email.utils import formatdate, make_msgid
import requests
re_title = re.compile("<title>(.*?)</title>")
re_title = re.compile("<title>(.*?)</title>", re.DOTALL)
AGENT = "Mozilla/5.0 (Windows NT 6.1) Gecko/20100101 Firefox/29.0"
headers = {"User-Agent": AGENT, "Accept": "text/html"}
@ -56,7 +56,7 @@ def find_not_here_message(html: str) -> str | None:
def get_title(html: str) -> str:
"""Title from web page."""
m = re_title.search(html)
return m.group(1) if m and m.group(1) else "no title"
return m.group(1).strip() if m and m.group(1) else "no title"
def check_conference(name: str, url: str) -> tuple[bool, str]: