PDA

View Full Version : Can't load HTML page with QNetworkReply



T4ng10r
18th September 2011, 19:15
Hi,
I want to download data from online shop site. For downloading I'm using QNetworkAccesManager and QNetworkReply. Main page loads correctly and without problem. On of next pages refuses to download and throw error - Host not found.


m_ptrPriv->m_pReply = m_ptrPriv->m_NetAccesMgm.get(QNetworkRequest(stUrl));
connect(m_ptrPriv->m_pReply, SIGNAL(finished()), this, SLOT(onPageDownloadFinished()));
connect(m_ptrPriv->m_pReply, SIGNAL(readyRead()),this, SLOT(httpReadyRead()));
connect(m_ptrPriv->m_pReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDataReadProgress(qint64,qint64)));

After finished() signal m_pReply contain error mentioned above. URL is http:/www.proline.pl/?p=AMD+X4+II+965+AM3+B.
I've tried program from QT Network examples - http. He returns the same problem. I can go to that addres by my browsers. HTML code of pages seems a little strange (addition of extra char '3D' in front of each TAG attributes value, which looks like some protection against web crawlers collecting data).
Any idea how to solve this problem? 'Host not found' suggest that QT couldn't find site by address. I thought that QNetworkReply should deliver HTML page code without parsing or validation - thats why I refuse to use WebKit.

ChrisW67
19th September 2011, 06:09
URL is http:/www.proline.pl/?p=AMD+X4+II+965+AM3+B.
This is not a valid URL. Try:


http://www.proline.pl/?p=AMD+X4+II+965+AM3+B
With the missing '/' Qt is finding no host name in the URL:


QUrl url("http:/www.proline.pl/?p=AMD+X4+II+965+AM3+B");
qDebug() << url.host() << url.scheme();

outputs:


"" "http"

T4ng10r
19th September 2011, 06:56
Dooh :) What a simple mistake. Thank you for help.