views:

158

answers:

4

I have a web page whose content I'd like to download into a wxString. For example, let's say that page is this:

http://www.example.com/mypage.html

And wxString would contain HTML source. In some other languages, say PHP for example, I would write something like this:

$html = file_get_contents('http://www.example.com/mypage.html');

I guess it is not a one-liner in wxWidgets, and I have peeked into wxHTTP class, but I wonder if there is some simple wrapper class that does the job with minimal code?

A: 

If you are running on windows you could use the Microsoft WinHTTP library. However, having a quick look at the wxHTTP documentation, WinHTTP probably isn't any easier.

Have a look at this straightforward wxHTTP sample code. It is doing exactly what you are after.

Cannonade
Excellent! Exactly what I needed. Thanks.
Milan Babuškov
Good stuff. Glad that was helpful.
Cannonade
I really don't understand why would anyone down-vote this?
Milan Babuškov
@milan-babuskov Thanks Milan. I am not sure what that is about either :)
Cannonade
A: 

You will evidently have to write your own wrapper.

But libcurl has a simpler interface that you may find easier to use, although this does add a new dependency to your program.

greyfade
And use wxCurl if you decide to use cURL. It will save you time.
George Edison
A: 

Check out libcurl
A quick google will find it.

Martin York
+4  A: 

If you're using C++, have you considered using ASIO? if so why not use Urdl? http://think-async.com/Urdl/doc/html/index.html

Beh Tou Cheh