From 320014e1577c0e22ae877dd035328c6327f151b4 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Sun, 24 Apr 2011 12:36:19 +0200 Subject: [PATCH] bookmarks my submissions from HN --- bin/hn2bookmarks.pl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 bin/hn2bookmarks.pl diff --git a/bin/hn2bookmarks.pl b/bin/hn2bookmarks.pl new file mode 100644 index 0000000..6967e51 --- /dev/null +++ b/bin/hn2bookmarks.pl @@ -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;