journee_mondiale: fix crash while parsing jmcom
This commit is contained in:
parent
0f0ab90062
commit
22848c184f
|
@ -126,7 +126,7 @@ class Bot(irc.client.SimpleIRCClient, Logger):
|
|||
except KeyboardInterrupt:
|
||||
self.log_i("Caught keyboard interrupt.")
|
||||
except Exception as exc:
|
||||
self.log_c(f"Caught unhandled exception: {exc}")
|
||||
self.log_c(f"Caught unhandled {type(exc)}: {exc}")
|
||||
_, _, exc_traceback = sys.exc_info()
|
||||
for line in traceback.format_tb(exc_traceback):
|
||||
self.log_d(line.rstrip())
|
||||
|
|
|
@ -81,12 +81,13 @@ class JourneeMondialePlugin(Plugin):
|
|||
try:
|
||||
items = soup.find("div", id="journeesDuJour").find_all("article")
|
||||
for item in items:
|
||||
entries.append(
|
||||
{
|
||||
"url": item.find("a")["href"],
|
||||
"title": item.find("h2").string,
|
||||
}
|
||||
)
|
||||
if (first_link := item.find("a")) is None:
|
||||
continue
|
||||
if (first_title := item.find("h2")) is None:
|
||||
continue
|
||||
link = first_link["href"]
|
||||
title = first_title.string
|
||||
entries.append({"url": link, "title": title})
|
||||
except (ValueError, KeyError):
|
||||
return ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue