Simpliest way to download html source from a website?
-
I have seen this example, "http://qt-project.org/doc/qt-4.8/network-http.html":http://qt-project.org/doc/qt-4.8/network-http.html
but it just seems so much code just to download one html file.
Until now, i have just accomplised to use qnetwork to see if we are connected to internet. But i am searching for something simple to download the html source of a website , like wget on linux.
-
there various thread and resources on the web.
For example "this":http://qt-project.org/forums/viewthread/29453/... -
The simple example for "downloading data from URL at our wiki might be also useful":http://qt-project.org/wiki/Download_Data_from_URL.
-
[quote author="raven-worx" date="1373637642"]there various thread and resources on the web.
For example "this":http://qt-project.org/forums/viewthread/29453/...[/quote]With this code
@QUrl url = "http://google.com";
QNetworkAccessManager manager;
QNetworkRequest request(url);
QNetworkReply *reply(manager.get(request));
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
qDebug(reply->readAll());@i always get the same output about something has been moved or something like it
for example
@<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>@[quote author="leon.anavi" date="1373649140"]The simple example for "downloading data from URL at our wiki might be also useful":http://qt-project.org/wiki/Download_Data_from_URL.[/quote]
With the code provided, pReply->readAll() outputs a blank line
-
Looking again the first first link i posted, it downloads an html file which looks like
@<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>@but also downloads another file which has the actual source of the website
raven-worx at your solution, how can reply->readAll() point to the other file and not at the html one?