mirror of
https://github.com/adulau/dotfiles.git
synced 2024-12-22 08:46:01 +00:00
bookmarks my submissions from HN
This commit is contained in:
parent
7bf6347b1b
commit
320014e157
1 changed files with 40 additions and 0 deletions
40
bin/hn2bookmarks.pl
Normal file
40
bin/hn2bookmarks.pl
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# http://news.ycombinator.com/submitted?id=adulau
|
||||||
|
|
||||||
|
use Scrappy;
|
||||||
|
|
||||||
|
my $spidy = Scrappy->new;
|
||||||
|
|
||||||
|
my $url = "http://news.ycombinator.com/submitted?id=adulau";
|
||||||
|
|
||||||
|
my @bookmarks;
|
||||||
|
|
||||||
|
sub hnfetch {
|
||||||
|
|
||||||
|
my $url = shift;
|
||||||
|
|
||||||
|
print STDERR "Fetching ".$url."\n";
|
||||||
|
$spidy->crawl( $url,
|
||||||
|
{
|
||||||
|
'table td a'=> sub {
|
||||||
|
if ($_[0]->{href} =~ m/^http/) {
|
||||||
|
push (@bookmarks, $_[0]->{href});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_[0]->{text} =~ m/^More$/) {
|
||||||
|
my $nextpage = "http://news.ycombinator.com".$_[0]->{href};
|
||||||
|
hnfetch($nextpage);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
hnfetch($url);
|
||||||
|
|
||||||
|
print @bookmarks;
|
Loading…
Reference in a new issue