Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This ruby script fetches all articles from an issue of the excellent periodical and send them to Instapaper. This script should be automated so it runs automatically when a new issue is available. Perhaps parsing the RSS?
# fetches the content of an issue and send it to Instapaper
# Stephan Burlot, Coriolis Technologies,
# First version Oct 10, 2013
# ruby was installed via homebrew, so the path to ruby is /usr/local/bin
# you may need to change it to the actual path of your ruby installation.
require 'nokogiri'
require 'open-uri'
require 'openssl'
# this is the issue number
issue = 5
# set these to your username and your password
user = "username"
password = "password"
# fetch the editorial page
doc = Nokogiri::HTML(open('' + issue.to_s + '/editorial.html'))
# look for the content's urls
doc.xpath('//div[@class="issue-cross-links"]').each do | section |
section.xpath('.//a[@href]').each do | link |
puts "Found article: " + link.content.to_s + " (" + link['href'].to_s + ")"
# set a custom title for the article
title = ' #' + issue.to_s + ' - ' + link.content.to_s
url = '' + title + \
"&url=" + link['href'].to_s
#puts "url : " + url
instapaper = open(URI::encode(url), {
:http_basic_authentication=>[user, password],
:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE})
# catch errors
rescue OpenURI::HTTPError => status_code
the_status =[0]
# status_code.message is the numeric code and text in a string
puts "Instapaper returned a bad status code: #{status_code.message}"
rescue NoMethodError
puts "issue-cross-links not found"
puts "End"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment