Sign up ×  I previously asked how to do this in Groovy. However,
now I'm rewriting my app in Perl because of all the CPAN
libraries.  If the page contained these links:  <a
href="">Google</a>  <a href="">Apple</a>  The output would be:
What is the best way to do this in Perl?  share|improve this
question  11 Answers 11  up vote 38 down vote accepted  Please
look at using the WWW::Mechanize module for this. It will fetch
your web pages for you, and then give you easy-to-work with
lists of URLs.  $mech->get( $some_url ); my @links =
$mech->links(); for my $link ( @links ) {     printf "%s, %s\n",
$link->text, $link->url;  Pretty simple, and if you're looking
to navigate to other URLs on that page, it's even simpler.  Mech
is basically a browser in an object.  share|improve this answer
I took the liberty of changing the print statement to include
the link text, as requested by melling. –  cjm Oct 31 '08 at
20:05  Have a look at HTML::LinkExtractor and HTML::LinkExtor,
part of the HTML::Parser package.  HTML::L