WHYY: support figures in articles
This commit is contained in:
parent
15ad286860
commit
4d28abcfa7
|
@ -686,7 +686,14 @@ class HandlerWHYYNews(Handler):
|
|||
if self.matching_classes(child, rejects):
|
||||
continue
|
||||
try:
|
||||
text = child.get_text().replace("\n", " ")
|
||||
if child.name == "figure":
|
||||
for img in child.find_all("img"):
|
||||
imgsrc = self.href(img, "src")
|
||||
for cap in child.find_all("figcaption"):
|
||||
caption = cap.get_text()
|
||||
text = f"=> {imgsrc} Figure: {caption}"
|
||||
else:
|
||||
text = child.get_text().replace("\n", " ")
|
||||
except AttributeError:
|
||||
continue
|
||||
if child.name in ["h1", "h2", "h3", "h4", "h5", "h6"]:
|
||||
|
|
Loading…
Reference in New Issue