Skip to content

Instantly share code, notes, and snippets.

@markchang
Created March 1, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markchang/1951457 to your computer and use it in GitHub Desktop.
Save markchang/1951457 to your computer and use it in GitHub Desktop.
Importing ReadItLater HTML into Readability via email
#
# this requires the nokogiri and mail gems
# this requires a sendgrid account, since you don't want to deal
# with setting up smtp delivery on your own machine
# sendgrid gives you 200 emails/day free
#
# 1. export from readitlater
# 2. separate the Unread and Archive sections (this doesn't distinguish URLs)
# 3. configure SMTP and email destination
# 4. go
require 'mail'
require 'nokogiri'
Mail.defaults do
delivery_method :smtp, { :address => "smtp.sendgrid.net",
:port => 587,
:domain => "yourdomain.com",
:user_name => "your_sendgrid_email@yourdomain.com",
:password => "your_sendgrid_password",
:authentication => 'plain',
:enable_starttls_auto => true }
end
# parse a file
f = File.open("unread.html")
doc = Nokogiri::HTML(f)
f.close
doc.xpath('//a').each { |a|
puts a['href']
mail = Mail.deliver do
to 'your_readability_inbound_email@inbox.readability.com'
from 'your_email_doesnt_matter@wherever.com'
subject 'none'
text_part do
body a['href']
end
end
sleep(1) # be nice
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment