kyleb
kyleb

Reputation: 2060

Controlling a webbrowser without c# webbrowser control

I want to be able to launch multiple browser windows and get the html from them and interact with them like I can with the .net web browser control. The problem is the c# web browser control requires STA threading and that makes my program slower and error prone. Is their a way I can talk to the real IE browser or even Chrome, Firefox etc and do this?

I know there is paid third party solutions and stuff but I was wondering if anybody knew of any free libraries that are reliable and work. I can't use HttpWebRequest for what I am doing, so don't suggest that please.

I will be running on Windows and using C#.

Upvotes: 0

Views: 3165

Answers (4)

Cyral
Cyral

Reputation: 14153

I have used WebKit.NET. Its free and works great (supports flash, css, renders correctly, has a javascript engine). It may or may not be to extensive for what you are doing.

http://webkitdotnet.sourceforge.net/

There are plenty of guides, and the demo has a fully featured tab system.

EDIT: I was fooling around with it, and made an enhanced version of the demo

enter image description here

Upvotes: 2

astro boy
astro boy

Reputation: 1430

For IE (only). Free: Microsoft Internet Controls

using SHDocVw;

Microsoft HTML Object Library

using mshtml;

With these you can do things like

foreach (InternetExplorer brIns in _allWindows)
            {
                var htmlDoc = brIns.Document as HTMLDocument;
                if (htmlDoc != null && htmlDoc.all.item(elementName) != null)
                {
                    var elem = htmlDoc.all.item(elementName) as HTMLInputElement;
                    if (elem != null && attributeName == null)
                    {
                        _ieCurrentDoc = htmlDoc;
                        _currentHtml = htmlDoc.documentElement.outerHTML;
                        return true;
                    }
                    if (elem != null && elem.getAttribute(attributeName) != null)
                    {
                        _ieCurrentDoc = htmlDoc;
                        _currentHtml = htmlDoc.documentElement.outerHTML;
                        return true;
                    }

                }
            }

Upvotes: 1

user111013
user111013

Reputation:

Awesomeium is a Webkit/Chromium (Chrome) based browser you can talk to via a .NET wrapper, much like the WebBrowser control. I'm not sure on the STA threading requirement though.

As for STA Threading making your application "slower and error prone" -- This sounds odd, perhaps you should investigate solving this.

Upvotes: 1

Related Questions