Skip to content

Instantly share code, notes, and snippets.

@bobes
Created April 13, 2011 06:18
Show Gist options
  • Save bobes/917059 to your computer and use it in GitHub Desktop.
Save bobes/917059 to your computer and use it in GitHub Desktop.

Revisions

  1. bobes created this gist Apr 13, 2011.
    27 changes: 27 additions & 0 deletions ril_to_instapaper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/usr/bin/env ruby

    # 1. export your RIL bookmarks
    # 2. save this file to the same directory where your ril_export.html is
    # 3. change username and password in the script bellow
    # 4. run 'ruby ril_to_instapaper.rb' in terminal

    require "cgi"
    require "net/http"
    require "net/https"

    ril = File.read("ril_export.html")

    unread = ril.scan(%r{<ul>.*?</ul>}m).first

    http = Net::HTTP.new("www.instapaper.com", 443)
    http.use_ssl = true

    unread.scan(%r{href="(.*?)".*?>(.*?)<}).each do |url, title|
    puts "#{url}: #{title}"
    http.post("/api/add", {
    :username => "[email protected]",
    :password => "top secret",
    :url => url,
    :title => title,
    }.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&"))
    end