Created
August 22, 2012 20:35
-
-
Save tekei/3429101 to your computer and use it in GitHub Desktop.
[google reader] star一覧抽出
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
# googleのstarred-items-jas.jsonのままだと処理しにくいため、 | |
# 一度単純なデータに変換する | |
# | |
# ファイル"bookmarks.json"に「登録時刻(time)/タイトル(title)/URL(url)」の | |
# 行列となったjsonファイルをはき出す | |
# | |
# 「情報をエクスポート」→「JSON アクティビティ ストリーム」から取得 | |
require 'json' | |
require 'time' | |
require 'open-uri' | |
f = open('starred-items-jas.json') | |
json = f.read | |
f.close | |
j = JSON.parse(json) | |
dat = j.first[1];nil | |
conv = [] | |
dat.each{ |l| | |
result = {"time" => Time.parse(l["published"])} | |
result["title"] = l["object"]["displayName"] | |
d = open(l["object"]["url"]) {|u| JSON.load u} | |
result["url"] = d["items"].first["alternate"].first["href"] | |
conv << result | |
} | |
open("bookmarks.json", "w") do |io| | |
io << JSON.pretty_generate(conv) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment