Skip to content

Commit

Permalink
feat: add image to process scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
seelengxd committed Sep 22, 2024
1 parent be5d353 commit fc64ff6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/src/scrapers/cna/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CNAArticle(BaseModel):
field_summary: str | None = None
description: str | None = None
release_date: str
image_url: str


async def process(category: str):
Expand Down Expand Up @@ -78,6 +79,7 @@ async def process(category: str):
source=ArticleSource.CNA,
body=body.strip(),
date=article.release_date,
image_url=article.image_url,
)
with Session(engine) as session:
session.add(article_orm)
Expand Down
2 changes: 2 additions & 0 deletions backend/src/scrapers/guardian/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class GuardianArticleFields(BaseModel):
model_config = ConfigDict(extra="allow")
bodyText: str
trailText: str | None = None
thumbnail: str | None = None


class GuardianArticle(BaseModel):
Expand All @@ -37,6 +38,7 @@ class GuardianArticle(BaseModel):
source=ArticleSource.GUARDIAN,
body=article.fields.bodyText,
date=article.webPublicationDate,
image_url=article.fields.thumbnail or "",
)
with Session(engine) as session:
session.add(article_orm)
Expand Down

0 comments on commit fc64ff6

Please sign in to comment.