tags:

views:

1476

answers:

6

Is there any browser I could embedd in C++ application on Windows?

I need all features typical browser has (HTTP client, cookies support, DOM style HTML parser, JavaScript engine) except rendering. Because I don't need rendering capability (and that's rather big part of a browser) I would prefer a browser with non monolithic design so I wouldn't have to include rendering stuff into my project.

It would be nice if it had C++ rather than C API.

I need this embedded browser mainly because I have much trouble finding C++ HTML parser which could handle broken HTML like browsers do.
If you know any, please answer Library Recommendation: C++ HTML Parser SO question or at least vote on it to increase a chance someone will give a good answer.

+5  A: 

Sounds like all you need is something like libcurl which is an HTTP library and will let you do GET/POST/etc.

When I think browser I generally think rendering/JavaScript and not HTTP library.

Edit

In that case I'd look at WebKit (which I think has a C++ API) and hope you don't have to pull too much in.

Edit Again

On second thought (since rendering is such a big part of what browsers do), you might be better off using a stand-alone JS engine like SpiderMonkey and a stand-alone XML parser like Xerces-C (plus maybe tidy to make your HTML into XML).

Aaron Maenpaa
So do I generally.
graham.reeds
I'm already using it. I need JavaScript engine and html parser and libcurl doesn't have these things.
Piotr Dobrogost
It would have been sensible to list those requirements in the question.
anon
@Neil: It was easier to say what I don't need since that's only one thing and all other features I need :)
Piotr Dobrogost
@Piotr ... yes and no. It's kind of obvious that we were confused about what you want ;)
Aaron Maenpaa
@Aaron: I was looking at Tidy but the first thing I check when I look for a library is how active the project is. The last entry in News section of Tidy project is one year old... I was also amazed there isn't any component based on Xerces-C which would handle HTML. There is such - called NekoHTML - but it's only for Xerces-Java. It's very sad there's no good, stand-alone HTML parser for such a popular language as C++...
Piotr Dobrogost
+2  A: 

How about Gecko ? You may not need the entire engine but you may find some its components useful like SpiderMonkey which is a JavaScript engine written in C.

teriz
+2  A: 

Including javascript support and html parsing makes this non-trivial task - you have to use one of the available browsers.

  • IE is usable through its COM model - you can create instance of it in your window be it invisible or not and call its javascript/html capabilities.

It has been designed to be used like that since the beginning and certainly it is working fine.

The other options are:

  • Gecko/Mozilla - a couple of years ago it wasn't usable like this, currently I think it is.

  • WebKit/V8 - no public API has been released for chrome yet, you could use webkit itself, but it doesn't have javascript engine. Another option is to take a look at the Chrome codebase and see if you could get out of it what you need.

I would probably go for IE, since it is maybe the easiest option and I have already used it. The other options seem to me more like building a browser instead of just using it.

devdimi
Thanks for pointing out Gecko and WebKit. I'd rather avoid IE and COM especially.
Piotr Dobrogost
+3  A: 

I'm a bit confused by your question regarding embedding a web browser for which you don't need rendering capabilities. A web browser is rendering web pages by definition, unless you just need HTTP and XML with JavaScript capabilities which is a subset of a browser functionalities?

If you need a web browser to embed in your C++ application, I would suggest to consider Qt that comes with the WebKit plugin. It is C++, LGPL and has a very nice IDE (Qt Creator). I tried Qt with Qt Creator on unix (Ubuntu) and it was very impressive. The debugger is a bit light but it is just the first version. The adapter of Qt into visual c++ 2008 is now free.

chmike
Yep, I need HTTP, cookies, HTML (not XML!) parser and JavaScript. I added all these to the question to make it even more clear :)
Piotr Dobrogost
I would then suggest to use webkit because it is quite efficient, especially the JavaScript interpretor. Just use the functionalities you are interested in.
chmike
+1  A: 

I'd recommend picking up Qt for C++ programming. It has a built-in library that embeds Webkit with all the bells'n'whistles, and Qt is a great C++ library in general.

Eli Bendersky
A: 

You might also want to check out Awesomium-- it's free for non-commercial use and has all of the features you're looking for (if you don't need rendering, simply don't use it).

Adam