Skip to content

Instantly share code, notes, and snippets.

@tily
Created December 29, 2009 16:13
Show Gist options
  • Save tily/265397 to your computer and use it in GitHub Desktop.
Save tily/265397 to your computer and use it in GitHub Desktop.
delete hatena diary entries interactively
require 'rubygems'
require 'highline'
require 'atomutil'
username = HighLine.new.ask('username: ')
password = HighLine.new.ask('password: ') {|q| q.echo = '*' }
auth = Atompub::Auth::Wsse.new :username => username, :password => password
client = Atompub::Client.new :auth => auth
uri_base = "http://d.hatena.ne.jp/#{username}/atom/blog?page="
count = 1
all_entries = []
begin
entries = client.get_feed(uri_base + count.to_s).entries
all_entries.concat(entries)
count += 1
end while entries.size != 0
all_entries.each do |entry|
print "delete? (y/n) [n] #{entry.title}:"
if STDIN.gets.chomp == 'y'
client.delete_entry(entry.edit_link)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment