Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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