Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How can I find the links in HTML tags?

by dchetlin (Friar)
on Sep 24, 2000 at 22:44 UTC ( [id://33855]=note: print w/replies, xml ) Need Help??


in reply to How can I find the links in HTML tags?

The following 4-liner uses HTML::Parser; it was both easy to code and correct — unlike any regex solution you're likely to see.

As coded, it assumes you're looking only for href links within anchor tags, but it is easily modified for other things, such as img tags.

use HTML::Parser; my $p = HTML::Parser->new( api_version => 3 ); $p->handler( start => sub { printshift->{href} if shift eq 'a' }, 'tag +name,attr' ); local $/; $p->parse(<>); #Just another URI finder

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://33855]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found