I've found a script that should parse all of the links from a web page. Seems pretty kool but can't get it working. I think I'm having problems interfacing with our proxy. Listed is the code found in "INSTANT PERL MODULES":
use strict; use LWP::UserAgent; use URI::URL; my $url = URI::URL->new('http://cnn.com'); my $base_url; #Creating new UserAgent browser my $ua = LWP::UserAgent->new(); #Agent named $ua->agent ("Netscape"); #Create HTTP request my $request = HTTP::Request->new(GET => $url); #Execute request my $response = $ua->request($request); #Check for success if ($response->is_success && $response->content_type eq 'text/html') { #request successful & html $base_url = $response->base(); print "Base URL: $base_url\n"; my $link_extor = HTML::LinkExtor->new(\&extract_links); $link_extor->parse($response->content); } else { #request failed print "Error getting document: ", $response->status_line, "\n"; } sub extract_links { my ($tag, %attr) = @_; if ($tag eq 'a' or $tag eq 'img') { foreach my $key (keys %attr) { if ($key eq 'href' or $key eq 'src') { my $link_url = URI->new($attr{$key}); my $full_url = $link_url->abs($base_url); print "LINK: $full_url\n"; } } } }
When running this script, I receive the error "Error getting document: 500 Can't connect to cnn.com:80"

In reply to LWP::NOT so simple by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.