This pattern seems
to be quite common. A little helper function might help with readability here and elsewhere:
def try_get_text(soup: BeautifulSoup, name: str, attrs: dict[str, str]) -> str:
if result := soup.find(name, attrs):
return result.text
return ""
Originally posted by @alexdewar in #263 (comment)