Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: how do i split a link

by Amoe (Friar)
on Apr 13, 2002 at 18:08 UTC ( #158818=note: print w/ replies, xml ) Need Help??


in reply to how do i split a link

sub gimmelinks { my $html = shift; my @linkywinkys; use HTML::TokeParser; my $parsee = HTML::TokeParser->new(\$html); while (my $tag = $parsee->get_tag('a')) { push @linkywinkys, {url => $tag->[1]->{href}, txt => $parsee->get_trimmed_text('/a')}; } return @linkywinkys; }

That should do you fine if you want to use good old HTML::TokeParser. You get the link text free as well! It returns an array of hashes, where the url is the "url" key and the text is the "txt" key. What am I saying - figure it out yourself :)

--
amoe


Comment on Re: how do i split a link
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-07-29 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (226 votes), past polls