Hi Monks,

I'm pondering a project which would involve fetching random web pages and displaying them via CGI script. A most vexing puzzle for me has been how to do this elegantly.

For example, if I fetch the page via WWW::Mechanize, I need to look for all img tags, href's, and anything else using a relative path and prepend the base URL of the site to it, before passing it on to the browser, if I want it to look "right".

But this gets real complicated real fast when dealing with javascript, css, and other assorted unexpected references--not to mention sites that gaurd against others using their images. I've even contemplated taking a screenshot of the page, but even then the perl modules I found depend on X windows based tools like Mozilla or Webkit, and I really don't want to have X Windows on my Linux server at all (and also my project involves making relevant changes such as highlights or underlines on the fly).

Is there an elegant way to fetch a page, and re-display it reliably?


In reply to Re-rendering web pages by rastoboy

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.