in reply to Re: replace relative links with absolute links
in thread replace relative links with absolute links

Good idea. can also use the

HTML::LinkExtor
URI::URL

modules. simple example:

#!/usr/bin/perl -w use strict; my @imgs; my $lx = HTML::LinkExtor->new(\&img); my $respond = LWP::UserAgent->new->request(HTTP::Request->new(GET => ' +http://www.ibm.com')); my $base = $respond->base; $lx->parse($respond->content); for(@imgs){ print "Relative: $_\n"; print "Full: ",url($_,$base)->abs,"\n\n"; } sub img{ my($tag,%links) = @_; push(@imgs,values %links) if($tag eq 'img'); }

Replies are listed 'Best First'.
Re: Re: Re: replace relative links with absolute links
by PodMaster (Abbot) on Jan 06, 2003 at 22:59 UTC
    HTML::LinkExtor is for extracting links, not altering HTML content. It's definetly the wrong tool for this job. HTML::Parser or HTML::TokeParser::Simple is what you'd wanna use here.

    update: here are some relevant links


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.