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. How to get/parse pastepin raw content using qt5 ?
Forum Updated to NodeBB v4.3 + New Features

How to get/parse pastepin raw content using qt5 ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 2.5k Views 3 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Oh, ok. So just for the record - that's not parsing. Parsing is a process of analyzing some input and transforming it into another form. what you seem to want is just fetching some data.

    The code you posted looks ok. For networking and signal/slot connections to work you need a running event loop (exec()). I'm assuming you don't have one as this is common mistake when writing a console app.
    Can you show your main() ?

    Btw. please surround code with ```, not html tags.

    1 Reply Last reply
    1
    • H Hanoosh

      @Chris-Kawa , i want to be able to parse the content into a Qstring , the example below is not working : ( PS. i need somthing very simple and console only no need for gui.)

      class MyClass : public QObject
      {
       Q_OBJECT
      public:
          MyClass();
          void fetch();
      
      public slots:
          void replyFinished(QNetworkReply*);
      
      private:
          QNetworkAccessManager* m_manager;
      };
      
      
      MyClass::MyClass()
      {
          m_manager = new QNetworkAccessManager(this);
      
          connect(m_manager, SIGNAL(finished(QNetworkReply*)),
               this, SLOT(replyFinished(QNetworkReply*)));
      
      }
      
      void MyClass::fetch()
      {
          m_manager->get(QNetworkRequest(QUrl("http://stackoverflow.com")));
      }
      
      void MyClass::replyFinished(QNetworkReply* pReply)
      {
      
          QByteArray data=pReply->readAll();
          QString str(data);
      
          //process str any way you like!
      
      }
      
      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @Hanoosh
      Hi
      Your code does work.
      please try
      https://www.dropbox.com/s/9gkycyliz0h6cyp/netreader.zip?dl=0

      H 1 Reply Last reply
      1
      • mrjjM mrjj

        @Hanoosh
        Hi
        Your code does work.
        please try
        https://www.dropbox.com/s/9gkycyliz0h6cyp/netreader.zip?dl=0

        H Offline
        H Offline
        Hanoosh
        wrote on last edited by
        #6

        @mrjj Thanks it works, is there anyway to make it simpler like in only one .cpp file with no header file?

        mrjjM 1 Reply Last reply
        0
        • H Hanoosh

          @mrjj Thanks it works, is there anyway to make it simpler like in only one .cpp file with no header file?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #7

          @Hanoosh
          Hi
          no. there must be .h file.
          the tool that make signal and slot works, called moc.exe, only reads .h files.
          So class MyClass : public QObject must be in a .h file.

          H 1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            Hi,

            In fact yes, it's possible, you have to include the moc file at the end of the .cpp file to force moc to parse the .cpp file. It's used for Qt's unit tests. Note that it's not the usual way to do it. @mrjj's solution is the good clean classic.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • mrjjM mrjj

              @Hanoosh
              Hi
              no. there must be .h file.
              the tool that make signal and slot works, called moc.exe, only reads .h files.
              So class MyClass : public QObject must be in a .h file.

              H Offline
              H Offline
              Hanoosh
              wrote on last edited by
              #9

              @mrjj Thanks for the info and help, how to make it support ssl link?

              mrjjM 1 Reply Last reply
              0
              • H Hanoosh

                @mrjj Thanks for the info and help, how to make it support ssl link?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #10

                @Hanoosh
                Hi
                Do you mean HTTPS ?

                H 1 Reply Last reply
                0
                • mrjjM mrjj

                  @Hanoosh
                  Hi
                  Do you mean HTTPS ?

                  H Offline
                  H Offline
                  Hanoosh
                  wrote on last edited by Hanoosh
                  #11

                  @mrjj yes, thanks

                  im getting this with https link:

                  QSslSocket: cannot call unresolved function SSL_CTX_new
                  QSslSocket: cannot call unresolved function SSL_library_init
                  QSslSocket: cannot call unresolved function ERR_get_error
                  mrjjM 1 Reply Last reply
                  0
                  • H Hanoosh

                    @mrjj yes, thanks

                    im getting this with https link:

                    QSslSocket: cannot call unresolved function SSL_CTX_new
                    QSslSocket: cannot call unresolved function SSL_library_init
                    QSslSocket: cannot call unresolved function ERR_get_error
                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #12

                    @Hanoosh
                    I think you need to set something with QSslConfiguration
                    and install OpenSSL binaries
                    https://forum.qt.io/topic/9376/solved-qnetworkaccessmanager-https-code-2-error-qnetworkreply-remotehostclosederror
                    (code in top)
                    request.setSslConfiguration(QSslConfiguration::defaultConfiguration());

                    for binaries
                    http://slproweb.com/products/Win32OpenSSL.html

                    This is purely guessing so you might want to wait to see if someone knows exactly.

                    .

                    H 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @Hanoosh
                      I think you need to set something with QSslConfiguration
                      and install OpenSSL binaries
                      https://forum.qt.io/topic/9376/solved-qnetworkaccessmanager-https-code-2-error-qnetworkreply-remotehostclosederror
                      (code in top)
                      request.setSslConfiguration(QSslConfiguration::defaultConfiguration());

                      for binaries
                      http://slproweb.com/products/Win32OpenSSL.html

                      This is purely guessing so you might want to wait to see if someone knows exactly.

                      .

                      H Offline
                      H Offline
                      Hanoosh
                      wrote on last edited by
                      #13

                      @mrjj Thanks, i've found the code below and i'm trying to implement in my code:

                      QNetworkAccessManager qnam;
                      QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
                      SslConfiguration.setProtocol(QSsl::SslV3);
                      QNetworkRequest req;
                      req.setSslConfiguration(sslConfiguration);
                      req.setUrl(QUrl("https://www.address.tld/"));
                      
                      QNetworkReply *rep = qnam->get(req);
                      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