简体   繁体   English

perl检查代理是否在线

[英]perl check if proxy is online

How can I check if a proxy is online and properly working with perl? 如何检查代理是否在线并正确使用perl? I was considering running a get operation and comparing output but i'll be running this check so frequently this overhead would be huge, any other more lightweight alternative? 我正在考虑运行一个get操作并比较输出,但我会运行这个检查,因此这个开销很大,任何其他更轻量级的替代品?

No, this is exactly how you do it. 不,这正是你如何做到的。 If you use a light-weight method such as HEAD, TRACE or OPTIONS instead, you cannot know whether the proxy is actually useful or censoring or even subtly subverting the unencrypted data. 如果您使用轻量级方法(如HEAD,TRACE或OPTIONS),则无法知道代理是否实际有用,或者是否审查或甚至巧妙地破坏未加密的数据。

You can keep the overhead small by testing against a minimal useful HTML document. 您可以通过针对最小的有用HTML文档进行测试来减少开销。

Like daxim said, I think that testing against a very small HTML document is going to be lightweight enough for most scenarios. 就像daxim所说的那样,我认为针对一个非常小的HTML文档进行测试对于大多数场景来说都是轻量级的。

The insuperable lightweight solution will be to use a web service that responds you with minimal data about your proxy IP address, if it is online and working fast enough, etc. This of course is going to include a third party(who's going to be doing the not so light work, doing the requests to all the proxies) and this, like everything, has their pros and cons. 无法轻松的轻量级解决方案将是使用一个Web服务来响应您的最小数据有关您的代理IP地址,如果它是在线和足够快的工作,等等。这当然将包括第三方(谁将会做不那么轻松的工作,向所有代理人提出要求)这和所有事情一样,都有其优点和缺点。

I use this proxy checker from Google code to do exactly what you need and I also obtain some more info of each IP address, like country and a couple of the proxy speed measurements. 我使用Google代码中的代理检查程序来完成您所需的操作,我还获得了每个IP地址的更多信息,例如国家/地区和一些代理速度测量。 It's a very simple code that consumes a web service from http://proxyipchecker.com/ . 这是一个非常简单的代码,它使用来自http://proxyipchecker.com/的Web服务。

PS: The example is in PHP but is trivial to do the same in Perl. PS:这个例子是在PHP中,但在Perl中做同样的事情是微不足道的。

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

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