I want to write a simple proxy that shuffles the text in the body of the requested pages. I have read parts of the twisted documentation and some other similar questions here on stackoverflow but I'm a bit of a noob so I still don't get it.
This is what I have now, I don't know how to access and modify the page
from twisted.web import proxy, http
from twisted.internet import protocol, reactor
from twisted.python import log
import sys
log.startLogging(sys.stdout)
class ProxyProtocol(http.HTTPChannel):
requestFactory = PageHandler
class ProxyFactory(http.HTTPFactory):
protocol = ProxyProtocol
if __name__ == '__main__':
reactor.listenTCP(8080, ProxyFactory())
reactor.run()
Can you please help me out? I'd appreciate a simple example (e.g. add something to the body etc...).