PDA

View Full Version : get website info with QWebPage



timmu
23rd August 2009, 11:40
I'd like to know how many bytes a website contains (let's say www.google.com).
I think I need to use QWebPage and bytesReceived() for that. However, I don't know how to specifify the URL for it.

This is what I have:


QWebPage * page = new QWebPage();
//missing code here
int bytes = page->bytesReceived();


but how do I specify the website URL to be opened for this?

wysota
25th August 2009, 09:10
You don't need QWebPage. Just download the page using QNetworkAccessManager and see how many bytes were received. Alternatively issue a HEAD request with QTcpSocket or QHttp and you'll receive information about the page size within the headers without the actual data.

timmu
25th August 2009, 09:15
Great, but which one of these options is easiest to use and fastest to execute when all I want is to detect whether or not a given website exists?

wysota
25th August 2009, 09:30
QTcpSocket with a HEAD request (or even without it but then connecting to a web server doesn't yet mean the website exists).