Better HN
topnewbestaskshowjobs
Log inSign up

rhett

6 karma · joined Mar 12, 2009 (17y ago) · 2 submissions

Submissions

comment 17y ago · link · parent

thanks, i didn't write it. I remembered that in some magazine from 1999. The link to the author is in the comment below

comment 17y ago · link · parent

Here is a web spider in 1 line: perl -MLWP::UserAgent -MHTML::LinkExtor -MURI::URL -lwe '$ua = LWP::UserAgent->new; while (my $link = shift @ARGV) { print STDERR "working on $link";HTML::LinkExtor->new( sub { my ($t, %a) = @_; my @links = map { url($_, $link)->abs() } grep { defined } @a{qw/href img/}; print STDERR "+ $_" foreach @links; push @ARGV, @links} )->parse(do { my $r = $ua->simple_request (HTTP::Request->new("GET", $link)); $r->content_type eq "text/html" ? $r-> content : ""; } ) }' http://www.google.com