Hello!
I've got problem with reading content of web pages using QNetworkAccessManager and QNetworkReply. I've got code:
void MainWindow::getXML()
{
qDebug() << "Getting content..." << endl;
QNetworkRequest request
(QUrl("http://www.google.pl"));
qDebug() << "Network request..." << endl;
NetRepl = NetAccMan.get(request);
qDebug() << "Network reply..." << endl;
connect(NetRepl, SIGNAL(readyRead()), this, SLOT(parseXML()));
qDebug() << "Connect..." << endl;
}
void MainWindow::parseXML()
{
qDebug() << "Ready to parse";
qDebug() << newData << endl;
[...]
}
void MainWindow::getXML()
{
qDebug() << "Getting content..." << endl;
QNetworkRequest request(QUrl("http://www.google.pl"));
qDebug() << "Network request..." << endl;
NetRepl = NetAccMan.get(request);
qDebug() << "Network reply..." << endl;
connect(NetRepl, SIGNAL(readyRead()), this, SLOT(parseXML()));
qDebug() << "Connect..." << endl;
}
void MainWindow::parseXML()
{
qDebug() << "Ready to parse";
QByteArray newData = NetRepl->read(2048);
qDebug() << newData << endl;
[...]
}
To copy to clipboard, switch view to plain text mode
It reads almost every content, but there are some pages that I can't get content (it doesn't go to parseXML()). For example my WWW server (it's simple http server based on small AVR controller) generates simple pages with data that I want to parse:
<RESP>
<FUNC>some_func</FUNC>
<VAL>true</VAL>
<DATA>
<D1>1</D1>
<D2>2</D2>
</DATA>
</RESP>
<RESP>
<FUNC>some_func</FUNC>
<VAL>true</VAL>
<DATA>
<D1>1</D1>
<D2>2</D2>
</DATA>
</RESP>
To copy to clipboard, switch view to plain text mode
Only this and nothing more. Do I need some header? How does it work because I'm a little bit confused.
thanks in advance
best regards
Tomasz
Bookmarks