Skip to content

Commit 9654bb6

Browse files
committed
updating to extract all links
1 parent a2a43ef commit 9654bb6

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

lambdas/security-newsletter/src/handler.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytz
88

99

10-
TABLE_ARN = os.environ["DYNAMODB_TABLE_ARN"]
10+
TABLE_ARN = "none" # os.environ["DYNAMODB_TABLE_ARN"]
1111
ARTIFACT_TYPE = "newsletter"
1212

1313
# Logging Configuration
@@ -32,12 +32,11 @@ def main(event, _):
3232
latest_articles = get_latest_article_with_timezone(all_articles)
3333

3434
logging.info("Latest articles: %s", latest_articles)
35-
36-
# Extract links from Bleeping Computer articles only
37-
bleeping_links = [article["link"] for article in latest_articles
38-
if "bleepingcomputer.com" in article["link"]]
39-
40-
return publish_message_to_table(bleeping_links)
35+
36+
# Extract links from all articles
37+
newsletter_links = [article["link"] for article in latest_articles]
38+
39+
return publish_message_to_table(newsletter_links)
4140

4241

4342
def get_latest_article_with_timezone(articles, timezone_str="UTC"):
@@ -50,8 +49,8 @@ def get_latest_article_with_timezone(articles, timezone_str="UTC"):
5049
for article in articles:
5150
date_str = article["published"]
5251
# Handle 'GMT' timezone suffix
53-
if date_str.endswith(' GMT'):
54-
date_str = date_str.replace(' GMT', ' +0000')
52+
if date_str.endswith(" GMT"):
53+
date_str = date_str.replace(" GMT", " +0000")
5554
try:
5655
parsed_date = datetime.strptime(date_str, "%a, %d %b %Y %H:%M:%S %z")
5756
except ValueError as e:
@@ -70,27 +69,32 @@ def fetch_bleeping_computer_rss(feed_url="https://www.bleepingcomputer.com/feed/
7069
raise ValueError(f"Error parsing feed: {feed.bozo_exception}")
7170
articles = []
7271
for entry in feed.entries:
73-
articles.append({
74-
"title": entry.title,
75-
"link": entry.link,
76-
"published": entry.published,
77-
"summary": entry.summary,
78-
})
72+
articles.append(
73+
{
74+
"title": entry.title,
75+
"link": entry.link,
76+
"published": entry.published,
77+
"summary": entry.summary,
78+
}
79+
)
7980
return articles
8081

82+
8183
def fetch_hacker_news_rss(feed_url="https://feeds.feedburner.com/TheHackersNews"):
8284
"""Fetch articles from The Hacker News RSS feed."""
8385
feed = feedparser.parse(feed_url)
8486
if feed.bozo:
8587
raise ValueError(f"Error parsing feed: {feed.bozo_exception}")
8688
h_articles = []
8789
for entry in feed.entries:
88-
h_articles.append({
89-
"title": entry.title,
90-
"link": entry.link,
91-
"published": entry.published,
92-
"summary": entry.summary,
93-
})
90+
h_articles.append(
91+
{
92+
"title": entry.title,
93+
"link": entry.link,
94+
"published": entry.published,
95+
"summary": entry.summary,
96+
}
97+
)
9498
return h_articles
9599

96100

0 commit comments

Comments
 (0)