PDA

View Full Version : How to save webpage in QT webkit as “save as complete webpage”



kokilakr
9th June 2010, 08:44
Hello,

I need to save web page using QT webkit similar to "Save as complete webpage".

Following are my requirements,

1. Save the index html file, maintaining entity encoding.
2. Need to download all linked images and other resources.
3. Need to change resource path in html page to local downloaded path.
4. Need to maintain webpage current state.

I need to do it using standard DOM and QWebElement.

Please provide me some inputs on this.

Thanks

kokilakr
14th June 2010, 09:08
Hello,

I need to move this thread to "Qt Programming". How to do that?

Thanks,

wambagilles
6th April 2011, 22:39
do some one know how to do it, please!

Rok
22nd June 2011, 10:19
I don't know if this thread is still active but I stumbled upon it while looking for answers for a QtWebkit problem I'm facing. Anyway...

I would go about this by using my own QNetworkAccessManager based class. Create a slot function that is connected to the finished signal from that class. I haven't tested this theory, but it should be something along the lines of -


void QNAMProxy::HandleFinished( QNetworkReply* reply ) {
if( reply->error( )) {
// Something went wrong
} else {
QUrl url = reply->url( );
//TODO Parse the URL to create your local path
QFile file( "Parsed local file name" );
if (!file.open(QIODevice::WriteOnly)) {
// Some problem with creating the file to write
} else {
file.write( reply->readAll( ));
file.close( );
}
}
}

This should give you the basis of what you need.

prabhakaran
3rd October 2011, 11:13
If you want to save the page as html

webPage->currentFrame()->toHtml() => QString

lhg
10th October 2011, 05:57
prabhakaran; I don't see this function "toHtml", have I missed something?
I want to get the page's html and that's it.