A few days ago I’ve discovered that Thumbshots.org stopped to deliver web page screenshots for my DNS checking tool.
I don’t know when it happened, at some point back in time I’ve noticed that they are serving a placeholder image instead of screenshots. After a quick investigation I’ve found that they have a quota for the free usage tier now.
I’m missing the thumbnails, they make the reports to look more attractive with a better look and feel. I’ve checked for alternatives and I’ve found nothing to satisfy my needs. Considering today’s ridiculous prices of a VPS and bandwidth I decided that I would implement a simple service which will generate web page screenshots and store them on Amazon S3.
The first thing which came into my mind was PhantomJS, I could generate screenshots using PhantomJS. After analyzing Node.js gluing modules for PhantomJS I decided that I shouldn’t add another piece to manage in my stack. I settled to a Ruby solution, thanks to Capybara and Poltergeist it was trivial to implement:
After adding resizing capabilities with
I’ve packed the example as a Ruby gem (webshot):
$ gem install webshot
# Setup Capybara Webshot.capybara_setup! # Take a screenshot of Google's home page # and save it to a image file using png format webshot = Webshot::Screenshot.new webshot.capture "http://www.google.com/", "google.png"