开发者

Python, Twisted, Proxy and rotating the proxy server

I use the below to starting the reactor for fetching web pages... So...all pages I fetch use the proxy once the reactor starts. But...what if I want to rotate proxies? How do I do that using e.g. random.choice(proxy_list)

Thanks

site = server.Site(proxy.ReverseProxyResource('173.000.342.2开发者_如何学Python34', 8800, ''))
reactor.listenTCP(8080, site)
reactor.run()


Take a look at the implementation. Notice where it uses the supplied IP and port to set up a new connection with reactor.connectTCP. Subclass ReverseProxyResource and extend it to be able to connect to your randomly selected address.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜