in reply to Re: Re: Converting relative URLs to absolute URLs
in thread Converting relative URLs to absolute URLs

it is no problem, see
use URI::URL; print url("foo/test.html")->abs("http://www.sun.com/"),"\n"; print url("/foo/test.html")->abs("http://www.sun.com/"),"\n"; print url("foo/test.html")->abs("http://www.sun.com"),"\n"; print url("http://www.sun.com/foo/test.html")->abs("http://www.sun.com +/"),"\n";

Replies are listed 'Best First'.
Re: Re: Re: Re: Converting relative URLs to absolute URLs
by mkurtis (Scribe) on Mar 05, 2004 at 04:12 UTC
    But I don't know what form the urls will be in. Heres a flowchart:

    open FILE1
    open FILE2
    while FILE1 is open take the urls out of them and use LWP::robotua to get their content url is in $_.
    Parse the content for links using HTML::SimpleLinkExtor.
    Take the links from linkextor and run them through uri to make them all absolute and then print them to FILE2.
    When FILE1 is done, goto FILE2 and do the same thing.

    How would the URI portion of this work, I can't use esskar's method because I don't know what the base or the link is, the program will have to figure that out.

    Thanks

      well, if it starts with an http:// or similar, it probably will be a base
        yes I realize that esskar. The data in $_ will always be an absolute address. But how do I tell URI to only convert relative addresses if I don't know which ones are relative?

        Thanks