turning relative into absolute urls

Discussion in 'Perl Misc' started by Felix, Feb 11, 2004.

  1. Felix

    Felix Guest

    Hi -

    I need a perl function ("make_absolute")that turns all relative URLs
    in an html document into absolute URLs, using the URL from which the
    document was fetched as an argument (see script below), and then
    returns the updated, entire html document.

    I fiddled with Perl classes like URI and HTML:parsner but wasn't able
    to get it right. Thanks a bunch.

    #script:

    $content = get ($url);
    $content = &make_absolute ($content, $url);

    print $content; exit;

    sub make_absolute {

    # need code here

    }
    Felix, Feb 11, 2004
    #1
    1. Advertising

  2. Felix

    gnari Guest

    "Felix" <> wrote in message
    news:...
    > Hi -
    >
    > I need a perl function ("make_absolute")that turns all relative URLs
    > in an html document into absolute URLs, using the URL from which the
    > document was fetched as an argument (see script below), and then
    > returns the updated, entire html document.
    >
    > I fiddled with Perl classes like URI and HTML:parsner but wasn't able
    > to get it right. Thanks a bunch.


    I think it would be more productive, if you told us in what way you
    were not able to get it right with these. I am sure a lot of people here
    will gladly (gleefully, even) point out what you are doing wrong.

    do you need a general solution working with any valid HTML,
    or is the HTML structure a known and simple structure, that
    regexes would be able to handle?

    gnari
    gnari, Feb 11, 2004
    #2
    1. Advertising

  3. Felix

    Tore Aursand Guest

    On Wed, 11 Feb 2004 12:54:05 -0800, Felix wrote:
    > I need a perl function ("make_absolute")that turns all relative URLs
    > in an html document into absolute URLs, using the URL from which the
    > document was fetched as an argument (see script below), and then
    > returns the updated, entire html document.


    perldoc HTML::LinkExtor


    --
    Tore Aursand <>
    "Omit needless words. Vigorous writing is concise. A sentence should
    contain no unnecessary words, a paragraph no unnecessary sentences,
    for the same reason that a drawing should have no unnecessary lines
    and a machine no unnecessary parts." -- William Strunk Jr.
    Tore Aursand, Feb 11, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip

    relative vs absolute URLs?

    Flip, Nov 24, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    443
  2. Kyle James Matthews

    Relative vs. absolute URLs

    Kyle James Matthews, May 11, 2004, in forum: HTML
    Replies:
    3
    Views:
    604
  3. theo

    Relative/Absolute URLS

    theo, Feb 7, 2005, in forum: HTML
    Replies:
    17
    Views:
    820
  4. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    738
    Sriram Srivatsan
    Aug 12, 2008
  5. Rudi Ahlers
    Replies:
    11
    Views:
    804
    Aaron Bertrand [MVP]
    Apr 11, 2004
Loading...

Share This Page