Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Answer: How do I parse links out of a web page

by agent00013 (Pilgrim)
on Jun 22, 2001 at 19:39 UTC ( #90761=categorized answer: print w/replies, xml ) Need Help??

Q&A > HTTP and FTP clients > How do I parse links out of a web page - Answer contributed by agent00013

The Perl Cookbook has a good example:
#!/usr/local/bin/perl # xurl - extract unique, sorted lists of links from URL use HTML::LinkExtor; use LWP::Simple; $base_url = shift; $parser = HTML::LinkExtor->new(undef, $base_url); $parser->parse(get($base_url))->eof; @links = $parser->links; foreach $linkarray (@links) { local(@element) = @$linkarray; local($elt_type) = shift @element; while (@element) { local($attr_name, $attr_value) = splice (@element, 0, 2); $seen{$attr_value}++; } } for (sort keys %seen) { print $_, "\n"}
Hope this helps. /msg me if you need anything else.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2016-12-05 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (82 votes). Check out past polls.