2

I wrote a simple proxy script in Twisted and It works just fine:

from twisted.internet import reactor
from twisted.web import proxy, server
site = server.Site(proxy.ReverseProxyResource('example.com', 80, ''.encode("utf-8")))
reactor.listenTCP(80, site)
reactor.run()

The only problem is, I would like to modify the html that my script fetches from the 3rd party site before it renders the resource on my server. I'm not sure where in twisted/web/proxy.py I would insert/modify the code to do so.

Cristian
  • 495
  • 2
  • 9
  • 35
  • 1
    You are using `ReverseProxyResource`, but what you are describing sounds like a (forward) proxy to me. I think you will find this thread useful: http://stackoverflow.com/questions/9465236/python-twisted-proxy-and-modifying-content. – Shakkhar Apr 27 '16 at 05:46
  • thanks, that actually solved the problem! – Cristian Apr 27 '16 at 17:55

0 Answers0