Skip to content

Commit

Permalink
Bug fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanbobrowski committed Nov 15, 2024
1 parent 5aa8b38 commit ff42c65
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions blog2epub/crawlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,15 @@ def _get_blog_description(self, tree) -> str:

def _get_header_images(self, tree) -> list[ImageModel]:
header_images = []
for img in tree.xpath('//div[@id="header"]/div/div/div/p[@class="description"]/span/img/@src'):
img_obj = ImageModel(url=img)
self.downloader.download_image(img_obj)
header_images.append(img_obj)
xpaths = [
'//*[contains(@class, "wp-block-image")]//img/@src',
'//div[@id="header"]/div/div/div/p[@class="description"]/span/img/@src',
]
for xpath in xpaths:
for img in tree.xpath(xpath):
img_obj = ImageModel(url=img)
if self.downloader.download_image(img_obj):
header_images.append(img_obj)
return header_images

def _get_atom_content(self) -> bool:
Expand Down

0 comments on commit ff42c65

Please sign in to comment.