Reproducing a web page and add own content to it.

LaundroMat Laundro at gmail.com
Tue Apr 8 07:31:42 EDT 2008


Hi -

I'm working on a Django powered site where one of the required
functionalities is the possibility of displaying the content of
external pages, with an extra banner at the top where specific
information is displayed. In other words, I'm looking for a way to
reproduce an existing web page and add some HTML code to it. (I can't
think of an example right now, but the idea is similar to sites that
let you see an external page and have some site-specific text above it
(often stating that the content below is not part of the site the user
comes from)).

To test this, I've been downloading an external page, adding some text
to it and re-opening it in a browser (with the help of built-in
modules such as urllib2 etc). This works of course, but the external
page's links such as <img src="hello.png">, or <a href="help.html">
are evidently no longer correct.

Apart from parsing the whole file and trying to inject the external
site's domain in links such as the above (with the added inconvenience
of having to store the external page locally), is there an easier way
of accomplishing what I want?

Thanks,

Mathieu




More information about the Python-list mailing list