using a proxy with htmlagilitypack

c# html-agility-pack

Question

Basically, I want to utilize a proxy with HTML Agility Pack; I used to have the code to accomplish it earlier, but I lost it. Here is the code I have so far, which is functional. I googled this question, but I didn't find what I was seeking for. However, I had to activate proxies since I ran out of time working on a software I was creating.

    private void button1_Click(object sender, EventArgs e)
    {
        StringBuilder output = new StringBuilder();
        string raw = "http://www.google.com";
        HtmlWeb webGet = new HtmlWeb();
        webGet.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6";
        var document = webGet.Load(raw);


    }
1
1
8/23/2012 8:32:44 PM

Popular Answer

Use an abundance ofHtmlWeb.Load() which employs proxies. Two overload signatures exist:

HtmlDocument Load(string url, string method, WebProxy proxy, NetworkCredential credentials);
HtmlDocument Load(string url, string proxyHost, int proxyPort, string userId, string password);

Although I have no personal experience, I would anticipate that employing proxies in my code would be successful.

6
8/23/2012 8:40:54 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow