Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2016-10-24 07:07 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (303 votes). Check out past polls.