Created
October 22, 2015 00:43
-
-
Save ysakasin/1fb082cc9797fa016d40 to your computer and use it in GitHub Desktop.
Chromeから抽出したブックマークの階層を平坦化するRubyスクリプト
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
link = {} | |
HEADER = '<!DOCTYPE NETSCAPE-Bookmark-file-1> | |
<!-- This is an automatically generated file. | |
It will be read and overwritten. | |
DO NOT EDIT! --> | |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> | |
<TITLE>Bookmarks</TITLE> | |
<H1>Bookmarks</H1> | |
<DL><p>' | |
File.open('bookmarks_2014_12_03.html') do |f| | |
f.each_line do |line| | |
line.strip! | |
if line[0, 6] == '<DT><A' | |
params = line.split(' ') | |
link[params[1]] = line | |
end | |
end | |
end | |
File.open('bookmark.html', 'w') do |f| | |
f << HEADER | |
link.each_value do |tag| | |
f << "\t#{tag}\n" | |
end | |
f << '</DL><p>' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment