Can't load full html code from page
I want to load and parse this "full" html and I believed that Qt WebKit can do such stuff.
I tried to do it in that way:
PageLoader::PageLoader(const QUrl &url)
mWebPage = new QWebPage();
connect(mWebPage->mainFrame(),SIGNAL(loadFinished(bool)), this, SLOT(processPage()));
QWebFrame* frame = mWebPage->currentFrame();
QString webHtml = frame->toHtml();
file.open(QIODevice::WriteOnly | QIODevice::Text);
out << webHtml;
But in output file I have only plain html with links to *.js files in script tags.
Where is my problem?
sorry for my terrible English...
You download and display html code only of the file that you access on server. All other files are only linked with html script and and located somewhere in ram or temp.
You'll have to manually parse html code to get other files and download them in the same way.
But when I tried to render the loaded page from mWebPage:
QImage image(mWebPage->viewportSize(), QImage::Format_ARGB32);
QImage thumbnail = image.scaled(400, 400);
It definitely has all js, images, css etc. files somewhere ( ram or internet temporary files). But as I looked through the docs, I didn't found any useful functions to access that data.
So you'll probably have to write your own program that will strip those files out, download them and changed links between those files that will match those on your hard drive.
And what you get is entire html file produced by server. For all the other files ( js, css, images), WebKit does the same for all the other files that are linked to your "main" file ( note: files can be included in files etc... ( recursion)).
Thank you! I'll try that:)