I have way too many projects as it is, but I keep adding to the pile. For quite some time, I’ve been lamenting the fact that there is no good headless browser for the .NET runtime (IMO). There are ways to drive a full-fledged browser (Watin), there are simple implementations (SimpleBrowser, etc), and then there is the option of trying to host a Java-based browser inside your .NET app (HtmlUnit). I have written plenty of web automation using existing libraries like this, but they usually run into issues. Using Watin in a multi-threaded content crawler, for example, usually results in memory exhaustion or a bunch of COM/Interop exceptions when trying to walk 90,000 pages.
So this prompted me to finally take the plunge and take a shot at writing a purely .NET, headless web browser. Sounds crazy, but after a day into it I am a lot further along than I thought. The great thing about modern software development is that a lot of the components you need are usually already out there. My goal:
- Develop a fully-functional, fully-compliant, purely .NET Level 3 Document Object Model. I think I’ve managed to achieve Level 1 compliance in the first day and I am attempting to add Level2 and Level 3 compliance today.
- Fully support JavaScript and CSS. JavaScript support is achieved through the use of the Jint library.
- Retain a small memory fingerprint.
After one day the browser is able to perform simple requests and perform simple JavaScript tasks (jQuery support is still a way off, though):
var WebBrowser = new WebBrowser()
{
EnableJavascript = true,
EnableDotNet = false,
Timeout = 15000,
UserAgent = new Firefox9Agent()
};
Browser.NavigateTo("http://www.google.com/");
Browser.CurrentDocument.Forms[0]
.Populate(f => f.SetValue(f.FindById("q"), "KLF Web Browser"))
.Click(e => e.id.Equals("btnG"));



















Wow. I would not have expected to ever see this college football match-up for quite a while, but the EWU Eagles will be playing the upper-division UW Huskies on September 3rd, 2011. While the Eagles did win the FCS national title last year, they go into this game down 14 of their seniors from last year, including J.C. Sherritt and star Taiwan Jones who was the 4th round draft pick of the Oakland Raiders (good luck with that). I would have been curious to see last year’s championship team play UW, but I have misgivings about this match. It’s good for EWU to play an upper-division school and maybe get another in-state rivalry going, but at the same time I’m dreading the actual outcome! All I can say is, “GO EAGLES!”