← Back to posts

How I built an automated news section for my blog using Python and Claude API

I wanted a section on my blog that stayed fresh without me having to write every day. The idea was simple: pull real news from the sources I already follow, let AI pick what’s actually worth reading for someone working in cloud and automation, write a short article about it, and publish it automatically.

Here’s how I built it end to end.


The architecture

The whole pipeline runs on the same AWS EC2 instance that hosts the blog. No extra infrastructure, no additional services. Just a Python script and a cron job.

RSS Feeds (10+ sources)
        ↓
Python fetches candidates
        ↓
Claude API picks the best story and writes the article
        ↓
Saved as Markdown in content/news/
        ↓
Hugo builds the site
        ↓
Nginx serves it

Twice a day, automatically. Zero manual intervention.


Step 1 — Collecting candidates from RSS feeds

The script pulls from 10 sources covering the areas I care about: AWS, Azure, GCP, OpenAI, Anthropic, GitHub, Kubernetes, Docker, and TechCrunch AI.

FEEDS = [
    "https://aws.amazon.com/blogs/aws/feed/",
    "https://aws.amazon.com/blogs/devops/feed/",
    "https://openai.com/blog/rss.xml",
    "https://www.anthropic.com/rss.xml",
    "https://feeds.feedburner.com/blogspot/gJZg",
    "https://github.blog/feed/",
    "https://kubernetes.io/feed.xml",
    "https://www.docker.com/blog/feed/",
    "https://techcrunch.com/category/artificial-intelligence/feed/",
    "https://azure.microsoft.com/en-us/blog/feed/",
]

For each feed it grabs the 3 most recent entries — title, summary, source name, and link. That gives roughly 25-30 candidates per run.


Step 2 — Letting Claude pick and write

Instead of using keyword filters to pick a story, I pass all 25-30 candidates to Claude and ask it to:

  1. Pick the single most relevant story for someone working in cloud and automation
  2. Ignore business deals, funding rounds, consumer tech, and anything without technical depth
  3. Write a 3-4 paragraph article explaining what it is, how it works, and why it matters practically
message = client.messages.create(
    model="claude-haiku-4-5",
    max_tokens=1500,
    messages=[{
        "role": "user",
        "content": f"""You are writing for a tech blog focused on Cloud, AI, and Automation.

Pick the SINGLE most relevant item from these candidates and write a blog post about it.
Prefer: AWS/Azure/GCP features, AI model releases, DevOps tools, automation frameworks.
Ignore: business deals, funding news, consumer products, social media.

{candidates_text}

Format: CHOSEN_INDEX, CHOSEN_LINK, CHOSEN_SOURCE, then the article."""
    }]
)

Using Claude as the filter is much more reliable than keyword matching. It understands context — it knows that “OpenAI acquires a podcast” is not technically relevant, even if it contains the word “AI”.


Step 3 — Saving the article with metadata

The script parses Claude’s response, extracts the article and the source link, and saves it as a Hugo Markdown file with proper frontmatter:

frontmatter = f"""---
title: "{title}"
date: {datetime.now().strftime("%Y-%m-%dT%H:%M:%S")}+00:00
draft: false
source_name: "{source_name}"
source_url: "{source_url}"
---
"""

The source_url is the exact link to the original article. Each news post shows a clickable source link at the bottom so readers can go to the original.


Step 4 — The Hugo template for /news

I created a dedicated section in Hugo for news at content/news/ with its own layout templates — separate from the main blog posts. The single page shows the full article with the source link at the bottom:

{{ with .Params.source_url }}
<div class="source-block">
  <span>Source</span>
  <a href="{{ . }}" target="_blank">↗ {{ $.Params.source_name }}</a>
</div>
{{ end }}

Step 5 — Automating with cron

Two cron jobs handle the publishing schedule:

0 8  * * * cd ~/lucianosblog && source ~/.bashrc && python3 generate_news.py && hugo build
0 18 * * * cd ~/lucianosblog && source ~/.bashrc && python3 generate_news.py && hugo build

8am and 6pm UTC. The site rebuilds in under 100ms so there’s no downtime.


Cost

The whole thing runs on the AWS free tier EC2 instance I already had. The only variable cost is the Claude API — using claude-haiku-4-5, the cheapest model, each article costs roughly $0.001. Two articles a day for a month comes to about $0.06. Essentially free.



Find me on LinkedIn if you want to talk automation.