----- Original Message ----- From: "Chris" <[EMAIL PROTECTED]> To: <perl-win32-users@listserv.ActiveState.com> Sent: Thursday, March 09, 2006 4:29 AM Subject: WWW::Mechanize
> I'm trying to retrieve a list of links. The documentation for this module is > not very clear. > > - Chris > > > use WWW::Mechanize; > my $mech = WWW::Mechanize->new(); > > $url='http://www.google.com'; > $mech->get( $url ); > > print (join "\n",$mech->links()); > use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $url='http://www.google.com'; $mech->get( $url ); @links = $mech->links(); # @links is a list of array references - one array reference for # each link. # Now dereference the arrays, printing out the elements we want # to see namely the 2nd element (the link as named on the web # page) and the first element (the actual link). for(@links) {print "Link Name: ${$_}[1]\nActual Link: ${$_}[0]\n\n"} __END__ Some of those links will appear as relative links. For example, the third last link I get is '/ads/' - which is really 'http://www.google.com/ads/'. Cheers, Rob _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs