用python写一个反向代理,给个简单的示例看看?
搜了好久没有搜到。。。
===========================================
最后还是搜到了。
import BaseHTTPServer import hashlib import os import urllib2 class CacheHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): m = hashlib.md5() m.update(self.path) cache_filename = m.hexdigest() if os.path.exists(cache_filename): print "Cache hit" data = open(cache_filename).readlines() else: print "Cache miss" data = urllib2.urlopen("http://targetserver" + self.path).readlines() open(cache_filename, 'wb').writelines(data) self.send_response(200) self.end_headers() self.wfile.writelines(data) def run(): server_address = ('', 8000) httpd = BaseHTTPServer.HTTPServer(server_address, CacheHandler) httpd.serve_forever() if __name__ == '__main__': run()
=============================
应该是我描述的不清楚。这个基本上就是我想要的了。
http://sharebear.co.uk/blog/2009/09/1...
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
https://pypi.python.org/pypi/proxylet...
https://github.com/bgnori/gae-reverse...
满街都是你到底是怎么搜的 ..?