Skip to content

Instantly share code, notes, and snippets.

@tekei
Created July 31, 2012 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekei/3219437 to your computer and use it in GitHub Desktop.
Save tekei/3219437 to your computer and use it in GitHub Desktop.
convert bookmark from diigo to instapaper
# http://www.diigo.com/tools/exportからRSS Formatで取得したファイルを
# import.txtとして保存して実行
# 量が多いと、Rate Limit Exceededになるので注意
require "cgi"
require "net/https"
ril = File.read("import.txt")
unread = ril.scan(%r{<link>(.*?)</link>}m)
http = Net::HTTP.new("www.instapaper.com", 443)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
unread.each do |url|
s = {
:username => "<username>",
:password => "<password>",
:url => url.first[/<!\[CDATA\[(.*?)\]/,1],
:selection => "(diigo import)"
}
param = s.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&")
puts param
http.post("/api/add", param)
puts "---------------"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment