Back

Freddie Alerts — Never miss a new Freddie

A scraper + notifier that watches Mailchimp giveaways and pings me the moment a new Freddie drops.

Freddie Alerts - All gone state

A small utility that scrapes mailchimp.com/replyall on an interval and alerts me if a new Freddie is available. These giveaways vanish fast, so the goal was simple: check often, compare against the last seen Freddie, and notify immediately.

Dismayed to miss out on the Gold Freddie, I vowed to never let it happen again.

What it does

  • Scrape a page and capture the current Freddie id.
  • Compare it to the stored value; update when it changes.
  • Send an email if a new Freddie appears.

Built with Ruby, Nokogiri, Heroku Scheduler, and Mailgun.

How it works

Nokogiri

Nokogiri parses the Reply All page, pulling the firstdiv.freddie element to identify the currently featured Freddie.

doc = Nokogiri::HTML(open("http://www.mailchimp.com/replyall"))
@freddies = doc.css("div.freddie")

@active_freddie = @freddies.first['id']

The fetched id is compared against the stored id; if they differ, a notification is triggered and the stored value is updated.

if @active_freddie != old_freddie
  # Send notification
  # Update stored Freddie value
end

Heroku Scheduler

Scheduler runs the scraper task hourly so the window to grab a free Freddie stays small.

task :default do
  desc "Scrape the page task run by Scheduler"
  get_freddie
end
Heroku Scheduler UI showing the task

Mailgun

Mailgun fires the email when a new Freddie is detected so I can claim it before it disappears.

Mailgun notification email for a new Freddie

Configuration

Environment variables are stored locally in .env and in the Heroku app config:

DATABASE_URL=<value>
MAILGUN_API_KEY=<value>
MAILGUN_FROM=<value>
MAILGUN_FROM_NAME=<value>
MAILGUN_TO=<value>
MAILGUN_TO_NAME=<value>