From 204cf6335ff17771e41d21c57461c3cf709399e0 Mon Sep 17 00:00:00 2001 From: Mateus Santos | mateussm Date: Tue, 19 Nov 2024 16:15:46 -0400 Subject: [PATCH] fix: News post images (#2) --- back/raspa_tacho/models/news_info.py | 9 ++++++--- back/raspa_tacho/services/tome/news.py | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/back/raspa_tacho/models/news_info.py b/back/raspa_tacho/models/news_info.py index 2fe6f7d..01ab4c6 100644 --- a/back/raspa_tacho/models/news_info.py +++ b/back/raspa_tacho/models/news_info.py @@ -7,13 +7,15 @@ def __init__( self, datetime, title, - src_image, + cover_image_src, + post_images_srcs, paragraphs, related_links, ): self.datetime = datetime self.title = title - self.src_image = src_image + self.cover_image_src = cover_image_src + self.post_images_srcs = post_images_srcs self.paragraphs = paragraphs self.related_links = related_links @@ -21,7 +23,8 @@ def __str__(self): return '\n'.join([ f'Datetime: {self.datetime}', f'Title: {self.title}', - f'Image src: {self.src_image}', + f'Cover image src: {self.cover_image_src}', + f'Post images srcs: {self.post_images_srcs}', '\n\n'.join(self.paragraphs), f'Related links: {self.related_links}' ]) \ No newline at end of file diff --git a/back/raspa_tacho/services/tome/news.py b/back/raspa_tacho/services/tome/news.py index d34c300..34584f6 100644 --- a/back/raspa_tacho/services/tome/news.py +++ b/back/raspa_tacho/services/tome/news.py @@ -21,7 +21,8 @@ def info(self) -> NewsInfo: """ raw_datetime = self.content.select('header ul .meta-date')[0].text title = self.content.select('.page-title')[0].text - # src_image = self.content.select('.panel .panel-body .container-fluid .row img')[0]['src'] + cover_image_src = self.content.select('.hero-section img')[0]['src'] + post_images_srcs = [image['src'] for image in self.content.select('.ct-container > article img')] raw_paragraphs = self.content.select('article p') raw_related_link_anchors = self.content.select('.panel .panel-body .panel-group .panel-default > a') raw_related_link_titles = self.content.select('.panel .panel-body .panel-group .panel-default > a p') @@ -38,9 +39,10 @@ def info(self) -> NewsInfo: return NewsInfo( str(datetime_object), title, - '', + cover_image_src, + post_images_srcs, paragraphs, - related_links + related_links, ) @staticmethod