forked from forks/microblog.pub
More Open Graph tweaks
This commit is contained in:
parent
c585f07857
commit
3d8d3efd25
1 changed files with 4 additions and 1 deletions
|
@ -44,12 +44,15 @@ def fetch_og_metadata(user_agent, links):
|
||||||
|
|
||||||
r = requests.get(l, headers={"User-Agent": user_agent}, timeout=15)
|
r = requests.get(l, headers={"User-Agent": user_agent}, timeout=15)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
if not r.headers.get("content-type").startswith("text/html"):
|
||||||
|
logger.debug(f"skipping {l}")
|
||||||
|
continue
|
||||||
|
|
||||||
html = r.text
|
html = r.text
|
||||||
try:
|
try:
|
||||||
data = dict(opengraph.OpenGraph(html=html))
|
data = dict(opengraph.OpenGraph(html=html))
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("failed to parse {l}")
|
logger.exception(f"failed to parse {l}")
|
||||||
continue
|
continue
|
||||||
if data.get("url"):
|
if data.get("url"):
|
||||||
res.append(data)
|
res.append(data)
|
||||||
|
|
Loading…
Reference in a new issue