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:
|
except KeyboardInterrupt:
|
||||||
self.log_i("Caught keyboard interrupt.")
|
self.log_i("Caught keyboard interrupt.")
|
||||||
except Exception as exc:
|
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()
|
_, _, exc_traceback = sys.exc_info()
|
||||||
for line in traceback.format_tb(exc_traceback):
|
for line in traceback.format_tb(exc_traceback):
|
||||||
self.log_d(line.rstrip())
|
self.log_d(line.rstrip())
|
||||||
|
|
|
@ -81,12 +81,13 @@ class JourneeMondialePlugin(Plugin):
|
||||||
try:
|
try:
|
||||||
items = soup.find("div", id="journeesDuJour").find_all("article")
|
items = soup.find("div", id="journeesDuJour").find_all("article")
|
||||||
for item in items:
|
for item in items:
|
||||||
entries.append(
|
if (first_link := item.find("a")) is None:
|
||||||
{
|
continue
|
||||||
"url": item.find("a")["href"],
|
if (first_title := item.find("h2")) is None:
|
||||||
"title": item.find("h2").string,
|
continue
|
||||||
}
|
link = first_link["href"]
|
||||||
)
|
title = first_title.string
|
||||||
|
entries.append({"url": link, "title": title})
|
||||||
except (ValueError, KeyError):
|
except (ValueError, KeyError):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue