use WWW::Mechanize(); my $mech = WWW::Mechanize->new(); my $html = $mech->get('http://umallvt.com/directory.php'); my @links= $mech->find_all_links( text_regex => qr/a/i ); foreach(@links){ if($_->url() eq 'http://www.victoriassecret.com/'){ print "\n"; print "url \n"; print $_->url(); print "\n"; print " text\n"; print $_->text(); print "\n"; } } _END_
The out put is :
url: http://www.victoriassecret.com/text: Victoria's Secret
In case the page had an anchor tag like below:
a href="http://www.victoriassecret.com/" target=_blank><img src=http://www.victoriassecret.com/nw.gif height=11 width=11 border=0 alt="Open this result in new window"> </anchor>
The above perl script would give :url: http://www.victoriassecret.com/
text: Open this result in new window
But the desired result is:url: http://www.victoriassecret.com/
text: IMAGE
In reply to Re^6: anchor text match
by kumar801012
in thread anchor text match
by kumar801012
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |