使用代理与web浏览器控件C#/。NET 3.5 [英] Use a proxy with webBrowser control C#/.net 3.5

查看:219
本文介绍了使用代理与web浏览器控件C#/。NET 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从别人谁已经使用WebBrowser控件连同proxys一些帮助。

我需要的是以下几点。

1 - 设置一个WebBrowser控件的代理。 2 - 加载特定网站。 3 - 在网站上执行的程序。 4 - 设置WebBrowser控件一个diferent代理。 5 - 装入另一个站点。 6 - 从点3号执行相同的常规

和的过程中保持在该方式,从proxys列表循环,直到全部都被使用。

不过。我有一些问题的应用程序。要做到这一点:

1 - 我使用连接到设置代理到WebBrowser控件code,但似乎在执行过程中的工作只有一次,当我在循环再次调用它,它只是不工作,我可以牛逼ounderstand为什么。

2 - 我有问题,来确定该页面完全加载,我的意思是,当我设置加载的第一个网站,我需要的程序等待,直到它完成加载,之后执行程序在它,并继续这一进程。

希望有一个人可以帮助我解决这个...

///我使用的功能-----------------------------

 私人无效SetProxy(字符串代理)
    {

        的MessageBox.show(设置:+代理);
        字符串键=SOFTWARE \\ \\微软的Windows \\ \\ CURRENTVERSION Internet设置;

        的RegistryKey REGKEY = Registry.CurrentUser.OpenSubKey(钥匙,真正的);
        RegKey.SetValue(访问代理服务器,代理);
        RegKey.SetValue(ProxyEnable,1);

    }
 

//该应用程序逻辑--------------------------------------

  SetProxy(190.97.219.38:80);
        WebBrowser1.Navigate时(http://www.whatismyip.com/);
        ExecuteRoutine();

        SetProxy(187.93.77.235:80);
        WebBrowser1.Navigate时(http://www.whatismyip.com/);
        ExecuteRoutine();

        SetProxy(109.235.49.243:80);
        WebBrowser1.Navigate时(http://www.whatismyip.com/);
        ExecuteRoutine();
 

解决方案

也许,这个链接是非常有用的:

<一个href="http://blogs.msdn.com/b/jpsanders/archive/2011/04/26/how-to-set-the-proxy-for-the-webbrowser-control-in-net.aspx" rel="nofollow">http://blogs.msdn.com/b/jpsanders/archive/2011/04/26/how-to-set-the-proxy-for-the-webbrowser-control-in-net.aspx

我测试了code和它似乎工作。但有两点非常重要:

  • 这是不兼容的编译模式项目任何CPU(X86正常工作)
  • 只是HTTP代理服务器;不是SOCKS

I need some help from someone who has already use the webBrowser control along with a proxys.

What I need is the following.

1 - Set a proxy for a webBrowser control. 2 - Load a specific site. 3 - Execute a routine over the site. 4 - Set a diferent proxy for the webBrowser control. 5 - Load another site. 6 - Execute the same routine from point number 3.

And the process keeps in that way, looping from a list of proxys, until all of them had been used.

But. I'm having some problems with the app. to do that:

1 - I'm using the code attached to set the proxy into the webBrowser control, but seems to work only once during the execution, when I call it again in the loop it just doesn't work, I can get t ounderstand why.

2 - I'm having problems to determine when the page has loaded completely, I mean, when I set the first site to load, I need the program to wait until it has finish to load, and after that execute the routine over it, and continue with the process.

Hope some one could help me with this...

/// The function that I'm using -----------------------------

    private void SetProxy(string Proxy)
    {

        MessageBox.Show("Setting :" + Proxy);
        string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";

        RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(key, true);
        RegKey.SetValue("ProxyServer", Proxy);
        RegKey.SetValue("ProxyEnable", 1);

    }

// The app logic --------------------------------------

        SetProxy("190.97.219.38:80");
        webBrowser1.Navigate("http://www.whatismyip.com/");
        ExecuteRoutine();

        SetProxy("187.93.77.235:80");
        webBrowser1.Navigate("http://www.whatismyip.com/");
        ExecuteRoutine();

        SetProxy("109.235.49.243:80");
        webBrowser1.Navigate("http://www.whatismyip.com/");
        ExecuteRoutine();

解决方案

Perhaps this link is useful:

http://blogs.msdn.com/b/jpsanders/archive/2011/04/26/how-to-set-the-proxy-for-the-webbrowser-control-in-net.aspx

I tested the code and it seemed to work. But two points are important:

  • It's not compatible to projects in compile mode "Any CPU" (x86 works fine)
  • JUST for HTTP proxy servers ; not for SOCKS

这篇关于使用代理与web浏览器控件C#/。NET 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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