PDA

View Full Version : Hot do I get HTML source from a web page?



earendil
18th April 2010, 20:18
I've been trying using this code, but failed:

QHttp *http;
http->setHost("subdivx.com");
http->get(QUrl::toPercentEncoding("/index.html"));

QByteArray text = http->readAll();
ui->textBrowser->setText(text);

As you can see, I just want to display the html code of some web page in a textBrowser.

What am I doing wrong here? Please, I need your help!

Thanks in advance!

Kumosan
18th April 2010, 21:07
Is this all your code or did you 'shorten' it a bit for our convenience? If this is what you really do, you might not understand the concept of asynchronicity. You cannot just sent a http request and at once try to read from QHttp. Connect a slot and wait for the signal, which tells you that your requested data actually arrived.

earendil
20th April 2010, 03:58
Ok. Thanks a lot. Finally, I made it work!! Thanks for the tip! It was very useful... really! :)

Roszko
14th March 2012, 21:35
Hi.
Can you put this code here? I'm started to learning programming in Qt, and I want write tool to finding something in source of page.

Thanks in advance.

PS. Sorry for my English :)

ChrisW67
15th March 2012, 01:43
Please do not use QHttp. Start with QNetworkAccessManager and the HTTP Example. For something more complex: Download Manager Example.

Roszko
15th March 2012, 14:35
Thanks a lot, but I don't need this. I want to make program which download only source, then finds lines which I'm interested in and makes list of these lines.
Please show explain how I can do this.

Thanks :)

ChrisW67
15th March 2012, 21:15
Thanks a lot, but I don't need this. I want to make program which download only source
Hmmm, that would be the bit I gave you

then finds lines which I'm interested in and makes list of these lines.
Please show explain how I can do this.
You do it by learning some basic programming, then reading the manual and trying to do it for yourself. Here are some places to start.
QFile or QBuffer, QRegExp, QString, QStringList.

wysota
15th March 2012, 22:24
I'm started to learning programming in Qt, and I want write tool to finding something in source of page.


Thanks a lot, but I don't need this.
If you expected to be given code that does exactly what you want then what would have that taught you? Certainly not programming... copy&pasting, maybe...

Roszko
16th March 2012, 14:56
@up.

I don't want ready code of course, but some example codes using these libraries.

Now when I know that what libs i have to use in code, I will try do it by myself

Again sorry for my English :P

wysota
16th March 2012, 15:15
You have been given an example and yet you said it was doing something else than what you wanted.