简体   繁体   English

使用phantomjs驱动程序C#在Selenium中进行代理

[英]Proxy in Selenium using phantomjs Driver C#

Im having trouble on adding a proxy in selenium using phantomjs driver. 我在使用phantomjs驱动程序在硒中添加代理时遇到麻烦。 This is my code: 这是我的代码:

            Proxy proxy = new Proxy();
            proxy.HttpProxy = string.Format("xxx.xx.xxx.xxx:xxxx");

            //options.AddAdditionalCapability(CapabilityType.Proxy, "xxx.xx.xxx.xxx:xxxx");
            service.ProxyType = "HTTP";
            service.Proxy = "222.88.236.236:81";
            service.HideCommandPromptWindow = true;
            service.IgnoreSslErrors = true;
            service.WebSecurity = false;
            service.LocalToRemoteUrlAccess = true;
            service.LoadImages = false;
            webDriver = new PhantomJSDriver(service, options);

This code here work sometimes. 此代码有时可以正常工作。 I'm just using List of proxy available in the web. 我只是使用网络上可用的代理列表。 Not so stable. 不太稳定。 And also can anyone explain to me the proxy authentication? 还有谁能向我解释代理身份验证?

Help me please. 请帮帮我。 Im so noob at this! 我真是个菜鸟! Thanks! 谢谢!

Your code is fine. 您的代码很好。 I guess the biggest problem you got is the proxies you got online.Most of the free proxies you find online were gathered by some port scan techs,which means they themselves are unstable and can be off-line at anytime(seconds to a few minutes). 我想您遇到的最大问题是在线上的代理。您在线上找到的大多数免费代理是由某些端口扫描技术收集的,这意味着它们本身不稳定,并且可以随时离线(数秒至几分钟) )。

Find a proxy provider that has it's own servers will solve your problem. 查找具有自己服务器的代理提供程序将解决您的问题。

And for the 'authentication', it depends on the provider you are using. 对于“身份验证”,它取决于您使用的提供程序。

The proxy i'm using have their own VIP mechanism. 我使用的代理有自己的VIP机制。 You have to be registered, and you have to pay for your proxies and then you can gen an 'API' link.Using this link,you can get your proxies whenever you want(by the HTTP GET method ). 您必须注册,并需要支付代理费用,然后才能生成“ API”链接。使用此链接,您可以随时通过HTTP GET方法获取代理。

Some providers can also let you modify the 'API',so that you can decide how many proxies you get at a time or how long you want your proxy to live ,etc. 某些提供程序还可以让您修改“ API”,以便您可以决定一次获得多少代理或希望代理存活多长时间等。

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

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