#!/usr/bin/perl use strict; use LWP::Simple; use HTML::Parser; my $in_article_body = 0; my $colin = HTML::Parser->new( start_h => [sub { my $self = shift; my ($tagname, $attr) = @_; if ($tagname eq "div" && $attr->{class} eq 'article') { $in_article_body = 1;; } }, "self, tagname, attr"], end_h => [sub { my $self = shift; my ($tagname) = @_; if ($tagname eq "div" && $in_article_body) { $in_article_body = 0; } }, "self, tagname"], text_h => [sub { my $self = shift; my ($origtext) = @_; print $origtext if $in_article_body; }, "self, text"]); my $topic = $ARGV[0] || 'perl'; my $url = "http://www.galactic-guide.com/cgi-bin/articlesearch.cgi?searchval=$topic"; my $string = get( $url ); # It works like Google's "I'm feeling lucky"-mode if ($string =~ /1\. parse( $text ); } else { print "There aren't pages about $topic\n"; }