Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Simpliest way to download html source from a website?
Forum Updated to NodeBB v4.3 + New Features

Simpliest way to download html source from a website?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 10.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      there various thread and resources on the web.
      For example "this":http://qt-project.org/forums/viewthread/29453/...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        The simple example for "downloading data from URL at our wiki might be also useful":http://qt-project.org/wiki/Download_Data_from_URL.

        http://anavi.org/

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Leon
          wrote on last edited by
          #4

          [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

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved