in reply to Re: mech follow_link question
in thread mech follow_link question
I tried the "follow" subroutine, thinking that if the if statement was false, it would return undef, but instead, the first link it tried to follow, which did NOT contain the string "contact" just crashed the program with the error message "Link not found at c:\websites\bla_bla\my_perl_script.pl". Why would mech assume the relative link was something off my hard drive instead of from the first fetched page????$m = WWW::Mechanize->new(); $m->get($url); # $url is some home page @links = $m->links(); for $link ( @links ) { &follow; } sub follow { if ($m->follow_link( url_regex => qr/contact/i)){ print "$link->url\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: mech follow_link question
by Corion (Patriarch) on Feb 19, 2012 at 15:37 UTC | |
by zingbust (Initiate) on Feb 29, 2012 at 17:51 UTC | |
by Corion (Patriarch) on Feb 29, 2012 at 19:11 UTC |