对每个Web浏览器控件使用不同的代理 [英] Use different proxy for each webbrowser control

查看:114
本文介绍了对每个Web浏览器控件使用不同的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在为公司创建网络自动化测试仪时遇到了一个小问题.我必须使用我公司的3台代理服务器来ping主服务器.我需要做的就是设置代理并浏览主服务器上的页面.

我正在使用vb.net和Web浏览器控件.我可以通过注册表设置更改代理,但一次只能用于1个浏览器.我的意思是所有3个都有相同的代理.你们知道我可以同时使用所有3种不同代理的任何方法吗?

我还决定尝试httprequests.我有一个示例代码来通过代理发布数据,但是如何使用httprequests浏览页面?

任何帮助将不胜感激.

Hi,

I am having a small problem creating a web automated tester for my company. I have to use 3 proxy servers of my company to ping main server. All i need to do is set their proxy and browse a page on main server.

I am using vb.net and a web browser control. I am able to change proxy through registry settings but that works only for 1 browser at a time. I mean all 3 will have same proxy. Do you guys know any method by which i can use all 3 different proxies at same time?

I also decided to give httprequests a try. I got a sample code to post data with proxy but how do i browse a page with httprequests ?

Any help would be appreciated.

推荐答案

WebBrowser控件使用IE中的当前设置.毕竟,它只是一个嵌入式IE控件.因此,您在IE中所做的更改会影响正在运行的IE的所有实例. WebBrowser控件也是如此.

您可以使用可以获取显式代理信息的HttpWebRequest类和HttpWebResponse类来获取所需的页面,然后将其发送到WebBrowser对象的DocumentText或DocumentStream属性.但是,您将必须管理所有链接的评估,并对构成单个网页的所有文件(例如图像...)提出额外的请求.
The WebBrowser control uses the current settings in IE. It IS just an embedded IE control after all. So, the changes you make in IE affect all instances of IE that are running. The same goes for the WebBrowser control.

You can use the HttpWebRequest class, which can take explicit proxy information, and HttpWebResponse classes, to grab the pages you need, then send them to the DocumentText or DocumentStream properties of the WebBrowser object. But, you''ll have to manage evaluating all of the links and making additional requests for all the files that make up a single web page, such as images...


这篇关于对每个Web浏览器控件使用不同的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆