Page 1 of 1

wxHtmlWindow and online images ?

Posted: Wed Sep 21, 2005 2:07 pm
by xtn
My probleme is simple, images On web pages I don't load doesn't appear
I added in my wxApp::OnInit the function

Code: Select all

wxInitAllImageHandlers(); 
as mentionned in the documentation.

My linked libraries are the following :
wxmsw26_html, wxmsw26_core, wxbase26, wxbase26_net, wxexpat, wxtiff, wxjpeg, wxpng, wxzlib

Take a look at the code ( I removed error's tests ) :

Code: Select all

    wxHtmlWindow *htmlban = new wxHtmlWindow(MainPanel, -1, wxDefaultPosition, wxDefaultSize, 0, "htmlpage");

    mainflexbar->Add( htmlban, 0, /*wxGROW|*/wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    wxURL url("http://www.google.com");
    wxInputStream *data = url.GetInputStream(); 
    wxFile fTest(".tmp.htm", wxFile::write );
    wxFileOutputStream streamout( fTest ); 
    data->Read(streamout);
    fTest.Close();
    htmlban->LoadPage(".tmp.html");
We have a nice google homepage downloaded... without any images :/

How can I handle that ?[/code]

Posted: Wed Sep 21, 2005 2:15 pm
by priyank_bolia
htmlban->LoadPage("www.google.com");

when you save it on disk, the path of the images in the folder is relative, so it won't load, when you laod priyank.in,you will see the images because the paths are complete.

Posted: Wed Sep 21, 2005 2:49 pm
by xtn
hmm I am sorry but I tried with "http://priyank.in/get.php", and this is the same, I get the page text, but still not the images ( there is image error icons instead of the image )

Re: wxHtmlWindow and online images ?

Posted: Wed Sep 21, 2005 2:55 pm
by phlox81
xtn wrote: wxFile fTest(".tmp.htm", wxFile::write );
htmlban->LoadPage(".tmp.html");
[/code]
is this just an error ?
What are the imagetags at the file you save ?
Are they 'local' (../img/test.jpg) or global (http://myurl.com/img/test.jpg) ?

Posted: Wed Sep 21, 2005 3:01 pm
by xtn
.tmp.htm is not an error, I put the dot to automatically hide the file under a linux like system.

The images paths from the URL "http://priyank.in/get.php" are all global ( As i said to us at the begining )

Posted: Wed Sep 21, 2005 3:04 pm
by phlox81
xtn wrote:.tmp.htm is not an error, I put the dot to automatically hide the file under a linux like system.

The images paths from the URL "http://priyank.in/get.php" are all global ( As i said to us at the begining )
you save *.htm and load *.html ...

Is there some kind of Firewall or something preventing the img Download ?
May be the control itself ?

Did you try loadFile ?

Posted: Wed Sep 21, 2005 3:05 pm
by priyank_bolia
htmlban->LoadPage("http://www.priyank.in/welcome.php");

the problem is images in the google.com have relative paths, not absolute. So you have to download the images also and put in the images folder under which you save the file.

Posted: Wed Sep 21, 2005 3:10 pm
by priyank_bolia
Also have a image in the same folder and try to load that say:
htmlban->LoadPage("test.jpg");
then also check that whether:
htmlban->LoadPage("http://www.priyank.in/images/priyank.jpg");
is working or not?

Posted: Wed Sep 21, 2005 3:16 pm
by xtn
priyank_bolia wrote: the problem is images in the google.com have relative paths, not absolute. So you have to download the images also and put in the images folder under which you save the file.
Ok, but in that way how to get the images ?

But, Priyank, problem is that I don't see the images with your site which as global paths to images ... ( the control displays a big error icon instead )

Is my code really correct ?

I have no firewall neither proxy that could block the application
phlox81 wrote: you save *.htm and load *.html
Yes a little copy/paste error :)

Posted: Thu Sep 22, 2005 4:16 am
by Vaulter
xtn wrote: Ok, but in that way how to get the images ?
at first, load to string tmp.html (htm)
then parse it by regex something like that:

Code: Select all

<img[^>src]+src=(('|")?[^'"\s]*('|")?)
then for all Matches(1) download images and save

Posted: Thu Sep 22, 2005 5:26 am
by priyank_bolia
Ok, I check it, the problem is that htmlwindow can not directly download the images, so you have to manually download it and put in a local folder and changes all the absolute path in the html to some path on the current hard drive where the image resides. To download images you can use Vaulter method to scan for the images and then you have to convert the relative paths to absolute URL then download them using wxURL, after that save them to the local disk.

Or

Try with wxMozilla... it more easier.

Posted: Thu Sep 22, 2005 8:13 am
by xtn
this works very well when I parse the page and download for the images.

Thank you all :D