Created
April 7, 2011 14:49
-
-
Save mxswd/907910 to your computer and use it in GitHub Desktop.
Tells you about your Chrome Bookmarks.
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
#!/usr/bin/ruby | |
# Go to chrome tools -> bookmark manager -> organize -> export -> call it bookmarks.html | |
# Run this from the same directory as the export | |
File.open('bookmarks.html', 'r') do |f| | |
urls, dups = [], [] | |
domains = {} | |
while line = f.gets | |
url = line.match(/<A HREF="([^"]*)"/) | |
if url | |
if urls.include? url[1] | |
dups << url[1] | |
else | |
domain = url[1].match(/:\/\/(www\.|)([a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3})/)[-1] rescue "Unknown" | |
urls << url[1] | |
domains[domain] += 1 rescue domains[domain] = 1 | |
end | |
end | |
end | |
puts "Bookmarks Analysis" | |
puts "Unique Bookmarks - #{urls.count}" | |
puts "Most Popular Domains:" | |
doms = domains.to_a | |
doms.sort! {|x, y| y[1] <=> x[1]} | |
doms[0..4].each do |d| | |
puts "\t#{d[1]} - #{d[0]}" | |
end | |
if dups.any? | |
puts "Duplicant Bookmarks - #{dups.count}" | |
dups.each do |d| | |
puts d | |
end | |
else | |
puts "No duplicant bookmarks." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment