【问题标题】:C# - xNet - how to add proxy supportC# - xNet - 如何添加代理支持
【发布时间】:2019-02-26 13:39:46
【问题描述】:

我为一些网站做了检查,但是,我需要添加代理支持:

using (var request = new HttpRequest())
{
       request.Proxy = new HttpProxyClient(ProxyRandom());
}

public static string ProxyRandom()
{
       Random rnd = new Random();
       return Proxies[rnd.Next(0, Proxies.Count)];
}

由于某种原因,它不起作用...当我尝试使用代理时,程序不会发布任何数据

当我使用 xNet 库时,添加代理支持的正确方法是什么?

【问题讨论】:

    标签: c# web proxy xnet


    【解决方案1】:

    我不知道 XNet 是什么,但是我查看了GitHub

    从页面上突出显示的示例中可以看出,您正在尝试将代理放入我认为是 主机名HttpRequest 构造函数中,请使用 request.Proxy 属性相反是我的猜测

    using (var request = new HttpRequest("Site name"))
    {
        request.UserAgent = Http.ChromeUserAgent();
        request.Proxy = Socks5ProxyClient.Parse("127.0.0.1:1080");
    

    【讨论】:

    • 谢谢 :),你能告诉我你用什么来发送 HTTP 请求而不是 xNet 吗?
    猜你喜欢
    • 2019-02-24
    • 2011-11-20
    • 2012-07-16
    • 1970-01-01
    • 2017-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多