|
Last change
on this file since 81 was
72,
checked in by peter, 12 years ago
|
- added the access log file to svn:ignore
- added the scan script to scan a bookmarks database and report how many links still appear to be active
- Bookmarks::get_bookmarks() defaults its parameters to {} before passing them on to Bookmarks::Search
|
-
Property svn:executable set to
*
|
|
File size:
784 bytes
|
| Rev | Line | |
|---|
| [72] | 1 | #!/usr/bin/perl -w |
|---|
| 2 | use strict; |
|---|
| 3 | |
|---|
| 4 | use Bookmarks; |
|---|
| 5 | use LWP::UserAgent; |
|---|
| 6 | use Text::CSV; |
|---|
| 7 | use Getopt::Long; |
|---|
| 8 | |
|---|
| 9 | GetOptions( |
|---|
| 10 | 'csv' => \my $CSV, |
|---|
| 11 | 'timeout=i' => \my $TIMEOUT, |
|---|
| 12 | ); |
|---|
| 13 | |
|---|
| 14 | my $DBFILE = shift or die "Usage: $0 <dbfile>"; |
|---|
| 15 | |
|---|
| 16 | $TIMEOUT ||= 10; |
|---|
| 17 | |
|---|
| 18 | my $bookmarks = Bookmarks->new({ |
|---|
| 19 | dbname => $DBFILE, |
|---|
| 20 | }); |
|---|
| 21 | |
|---|
| 22 | my $ua = LWP::UserAgent->new; |
|---|
| 23 | $ua->timeout($TIMEOUT); |
|---|
| 24 | |
|---|
| 25 | my $csv = Text::CSV->new; |
|---|
| 26 | |
|---|
| 27 | for my $bookmark (@{ $bookmarks->get_bookmarks->results }) { |
|---|
| 28 | printf "%3d %s\n", $bookmark->id, $bookmark->uri unless $CSV; |
|---|
| 29 | my $response = $ua->head($bookmark->uri); |
|---|
| 30 | printf " -> %s\n", $response->status_line unless $CSV; |
|---|
| 31 | $csv->combine( |
|---|
| 32 | $bookmark->id, |
|---|
| 33 | $bookmark->uri, |
|---|
| 34 | $response->code, |
|---|
| 35 | $response->message, |
|---|
| 36 | ); |
|---|
| 37 | print $csv->string . "\n" if $CSV; |
|---|
| 38 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.