Created
July 31, 2012 18:51
-
-
Save tekei/3219437 to your computer and use it in GitHub Desktop.
convert bookmark from diigo to instapaper
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
# 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