[facebook] add fallback to 'biography' extraction (#8233)

This commit is contained in:
Mike Fährmann
2025-09-20 22:28:19 +02:00
parent 8796ad02ba
commit b79d35e5f2
2 changed files with 16 additions and 2 deletions

View File

@@ -369,8 +369,12 @@ class FacebookExtractor(Extractor):
for edge in (user["profile_tabs"]["profile_user"]
["timeline_nav_app_sections"]["edges"])
]
user["biography"] = self.decode_all(text.extr(
page, '"best_description":{"text":"', '"'))
if bio := text.extr(page, '"best_description":{"text":"', '"'):
user["biography"] = self.decode_all(bio)
else:
user["biography"] = text.unescape(text.remove_html(text.extr(
page, ">Intro</span></span></h2>", "<ul>")))
except Exception:
if user is None:
self.log.debug("Failed to extract user data: %s", data)

View File

@@ -385,4 +385,14 @@ __tests__ = (
],
},
{
"#url" : "https://www.facebook.com/Forgetmen0w/info",
"#comment" : "'biography' fallback (#8233)",
"#class" : facebook.FacebookInfoExtractor,
"#auth" : True,
"#metadata": "post",
"biography": "G ❤️",
},
)