Redirecting to a third party site with injected HTML
Denis McMahon
denismfmcmahon at gmail.com
Mon Jun 10 03:59:10 EDT 2013
On Sun, 09 Jun 2013 10:09:17 -0700, guytamir1 wrote:
> i'm not really sure how to approach this problem..
> hints :)
Let me restate the problem for you:
You want to display a web page to a visitor that exists on a third party
website, with some of your own html inserted into it.
Setting aside the multitude of ethical, moral, legal and copyright
issues, the only technical solution I can see that doesn't involve
hacking the third party website is to scrape the third party website
using eg curl, modify the html using your scripting environment of choice
(I'll assume python) either using some form of dom manipulation or string
manipulation, and then server the modified page to the visitor.
so pycurl and pydom might be good places to start.
Don't forget that you may need to rewrite urls in the scraped document
for things such as anchors, images, css, javascript etc to point them
back at the host server, or some script on your server that can obtain
and serve the appropriate resources.
Alternatively, how about displaying the third party website in an iframe
within your own document? Although that's not really pythonic, just
htmlic.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list