use LWP; use HTTP::Request::Common; use strict; use constant URL => 'http://perlmonks.org/index.pl'; $|++; my $node = shift; print "USAGE: $0 [node_id]\n" and exit unless $node; my $ua = LWP::UserAgent->new; $ua->agent('node_grabber/1.0 (' . $ua->agent .')'); my $request = POST(URL, Content => [ node_id => $node ] ); my $response = $ua->request($request) or die "can't download id $node"; my $html = $response->content(); my ($date) = $html =~ /a>\s*on\s*([^<]+?)<\/font/i; my ($title) = $html =~ /([^<]+)<\/title>/; my $chunk; my @ends = ( qr|<BR>\s*<hr\s*\/>|, qr|<BR>\s+<BR><font size=2><I>|, qr|<CENTER>\s+back to <A HREF="|, qr|<BR>go see more <A HREF="|, qr|<center><TABLE width=|, ); foreach (@ends) { ($chunk) = $html =~ /<INPUT type=hidden name=op value=vote>(.*)(?:$_)/ms; last if $chunk; } unless ($chunk) { ($chunk) = $html =~ /<!--\s+-->(.*)(?:<!--\s+-->)/ms; } print "couldn't parse it :(\n" and exit unless $chunk; print "$title [$date]\n", $chunk;