in reply to Re^5: anchor text match
in thread anchor text match
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: anchor text match
by JadeNB (Chaplain) on Dec 31, 2009 at 00:05 UTC |