citizen428.blog()

Try to learn something about everything

Unsavory — Get Rid of Stale Delicious Bookmarks

While browsing through my Delicious bookmarks the other day, I realized that over time I had accumulated quite a few dead links (about 5% of my collection). I then looked for a simple tool to automatically remove them, but couldn’t find one that appealed to me, so I wrote my own script called unsavory which you can find on GitHub:

http://github.com/citizen428/unsavory/tree/master

It uses HTTParty to generate a list of all your bookmarks, which then get checked individually with Net::HTTP. Every link that returns an HTTP status code of 404 will automatically be removed (no questions asked, no undo), links with a status code other than 200 (OK) won’t be changed but will display some information in case you want to fix them manually. Here’s some example output (links anonymized for this post):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<span class='line'>Enter Delicious username: citizen428
</span><span class='line'>  Enter Delicious password: *********
</span><span class='line'>
</span><span class='line'>  citizen428 has 664 bookmarks.
</span><span class='line'>  Processing URL #0001: OK
</span><span class='line'>  Processing URL #0002: OK
</span><span class='line'>  Processing URL #0003: OK
</span><span class='line'>  Processing URL #0004: OK
</span><span class='line'>  Processing URL #0005: OK
</span><span class='line'>  ...
</span><span class='line'>  Processing URL #0013: 405: http://...
</span><span class='line'>  ...
</span><span class='line'>  Processing URL #0074: 302: http://...
</span><span class='line'>  ...
</span><span class='line'>  Processing URL #0086: Connection reset by peer - https://...</span>

Not bad for under 60 lines of code. :-) I hope this is useful to some of you, I do have some features I plan on adding to this in the future.

Comments

Copyright © 2016 - Michael Kohl - Powered by Octopress