将WebClient与袜子代理一起使用

编程入门 行业动态 更新时间:2024-10-26 07:40:07
本文介绍了将WebClient与袜子代理一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以在 WebClient 中使用袜子代理?特别是它提供的 DownloadString 方法?

Is there any way to use a socks proxy with WebClient? Specifically with the DownloadString method that it provides?

我不想使用任何第三方东西,例如privoxy,freecap,也不能使用Chilkat的商业库。我尝试使用 www.mentalis/ 中的内容,实际上我使用了它们的 WebRequest 实现,但WebClient似乎没有类似的东西。

I don't want to use any third party stuff like privoxy, freecap whatever and I can't use commercial libraries like those from Chilkat. I tried using stuff from www.mentalis/ in fact I used their WebRequest implementation but they don't seem to have something similar for WebClient.

推荐答案

WebRequest / WebResponse 类,通过扩展, WebClient 类(它依靠 WebRequest 来完成其工作)。

SOCKS is not supported directly by the WebRequest/WebResponse classes and by extension, the WebClient class (it relies on WebRequest to do its work).

它实际上不能,因为它在传输层(TCP / IP)上工作,而不是通过简单的重定向到转发HTTP请求的服务器(这是 WebRequest / WebResponse 类起作用)。

It really can't, as it works on the transport layer (TCP/IP) and not through a simple redirect to a server that forwards HTTP requests (which is the level that the WebRequest/WebResponse classes work on).

您可以创建 WebRequest / WebResponse (使用 ProxySocket 来处理低级别的握手,然后),然后创建一个专门的 WebClient 类会覆盖 GetWebRequest 和 GetWebResponse 方法。

You can create a specialized derivation of WebRequest/WebResponse (that uses ProxySocket to handle the low-level handshaking and then) and then create a specialized WebClient class which overrides the GetWebRequest and GetWebResponse methods.

一旦您用该类替换了 WebClient 实例,它应该可以正常工作(不过,在每种情况下都可能需要设置代理)。

Once you have that class substituted for your WebClient instances, it should work as normal (you might have to set up the proxy in each case where you use it though).

更多推荐

将WebClient与袜子代理一起使用

本文发布于:2023-11-23 11:14:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:袜子   WebClient

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!