Here's a script from 'Web Client Programming with Perl' that shows how to
expand relative URLs:

#!/usr/local/bin/perl
use LWP::Simple;
use HTML::Parse;
use HTML::Element;
use URI::URL;

$html = get $ARGV[0];
$parse_html = HTML::Parse::parse_html($html);

for (@{ $parsed_html->extract_links() }) {
    $link=$_->[0];
    $url = new URI::URL $link;
    $full_url = $url->abs($ARGV[0]);
    print "$full_url\n";
}


On 20 Jan 2000, Tkil wrote:

> >>>>> "Tac" == Tac/Smokescreen Action Network <[EMAIL PROTECTED]> writes:
> 
> Tac> Is there any way to request a page so that all the links have
> Tac> their full URLs?
> 
> Please take a look at 
> 
>    http://slinky.scrye.com/~tkil/perl/index.html#fully-qualify
> 
> Which I wrote in about 20 minutes, based on your suggestion.  It seems
> to do the right thing, although the s/// replacement of the original
> [relative] URL strikes me as fairly ugly.  The only other way I can
> see doing it, though, is to re-quote all the values in the %$attr
> hash.  neither one is very appetizing.  (Unless LWP has a "quote this
> politely" function for attribute values?  Wouldn't surprise me...)
> 
> Suggestions welcome.
> t.
> -- 
> Tkil * <URL: http://slinky.scrye.com/~tkil> * hopelessly hopeless romantic.
>   "So amplify this little one         |   She hears as much as she can see
>    She's a volume freak               |   And what she sees, she can't believe."
>         -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"
> 

Reply via email to