Created
March 1, 2012 17:09
-
-
Save markchang/1951457 to your computer and use it in GitHub Desktop.
Importing ReadItLater HTML into Readability via email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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