简体   繁体   English

Python,Twisted,Proxy和旋转代理服务器

[英]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 eg random.choice(proxy_list) 我该如何使用例如random.choice(proxy_list)

Thanks 谢谢

site = server.Site(proxy.ReverseProxyResource('173.000.342.234', 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 . 请注意,它使用提供的IP和端口在何处建立了与reactor.connectTCP的新连接。 Subclass ReverseProxyResource and extend it to be able to connect to your randomly selected address. 子类化ReverseProxyResource并将其扩展为能够连接到您随机选择的地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM