Skip to content

Commit

Permalink
Refactor link extraction logic in fetch_and_parse_articles
Browse files Browse the repository at this point in the history
  • Loading branch information
Cdaprod committed Mar 14, 2024
1 parent c1a670e commit ec73db4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def fetch_and_parse_articles():
author = 'David Cannan'
summary = article.select_one('div.post__content > p').text.strip() if article.select_one('div.post__content > p') else ''
date = article.find('time').text.strip() if article.find('time') else ''
link = article.find('h2').find('a')['href'] if article.find('h2').find('a') else ''

title_link = article.find('h2').find('a')
link = title_link['href'] if title_link else ''

articles.append((title, author, summary, date, link))

return pd.DataFrame(articles, columns=['title', 'author', 'summary', 'date', 'url'])
Expand Down

0 comments on commit ec73db4

Please sign in to comment.