Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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?
[erix]: another blues with Big Red :)
[stonecolddevin]: I will say John Mayer is an excellent guitarist, I don't like his music but he's pretty damn good
[erix]: scd: maybe you like John Mayall better :)
[erix]: (mayall = british blues)
[planetscape]: sleep well, Corion
[stonecolddevin]: erix seems pretty good, i listened to "So Many Roads" and it was nice. Not everyone's cup of tea but this guy can absolutely shred, he and the guy from Mastodon are definitely up there: https://www. youtube.com/watch? v=VzhMkSN9dQc

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-06-22 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.