views:

154

answers:

2

I am trying to emulate a web browser in order to execute JavaScript code and then parse the DOM. The System.Windows.Forms.WebBrowser object does not give me the functionality I need. It let's me set the headers, but you cannot set the proxy or clear cookies. Well you can, but it is not ideal and messes with IE's settings.

I've been extending the WebBrowser control pinvoking native windows functions so far, but it is really one hack on top of another. I can mess with the proxy and also clear cookies and such, but this control has its issues as I mentioned.

I found something called WebKit .NET (http://webkitdotnet.sourceforge.net/), but I don't see support for setting proxies or cookie manipulation.

Can someone recommend a c++/.NET/whatever library to do this:

Basically tell me what I need to do to get an interface to similar this in .NET:

// this should probably pause the current thread for the max timeout, 
// throw an exception on failure or return null w/e, VAGUELY similar to this
string WebBrowserEmu::FetchBrowserParsedHtml(Uri url,
                                             WebProxy p, 
                                             int timeoutSeconds, 
                                             byte[] headers,
                                             byte[] postdata);
void WebBrowserEmu::ClearCookies();

I am not responsible for my actions.

+1  A: 

Have you seen Watin?

Hun1Ahpu
I didn't look but does this have methods to clear cookies and use proxies? etc.
Joshua
errr I looked but I can't tell lol
Joshua
owow dude Watin freaking owns bro thanks
Joshua
+1  A: 

If you understand basic (beginner level) of java, you can give a try to Selenium.

Dunno if it offers all the functions you need but it's a powerful tool used to test webapps. It makes the browser you want run (firefox, ie, chrome...) and you can make the browser click on any item, execute javascript, parse dom with xpath, use proxy, you can set up a custom firefox profile to run with selenium... many powerful options.

It seems to be almost the same as Watin but for Java. Don't know Watin but i tried Selenium and was really surprised how powerful it was...

Sebastien Lorber