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 can I get things from website
Qt 6.11 is out! See what's new in the release blog

How can I get things from website

Scheduled Pinned Locked Moved Solved General and Desktop
73 Posts 5 Posters 34.7k 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.
  • V victor wang

    @jsulm
    It shows no error.
    That means everything was fine.
    But why still have nothing?
    Is there any possible because i receive a file?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #35

    @victor-wang Is that out variable a QByteArray?
    Also, what exactly does qDebug()<<out print out?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    V 1 Reply Last reply
    0
    • jsulmJ jsulm

      @victor-wang Is that out variable a QByteArray?
      Also, what exactly does qDebug()<<out print out?

      V Offline
      V Offline
      victor wang
      wrote on last edited by
      #36

      @jsulm
      I declared it at the mainwindow.h here.

      This is what it got here.

      jsulmJ 1 Reply Last reply
      0
      • V victor wang

        @jsulm
        I declared it at the mainwindow.h here.

        This is what it got here.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #37

        @victor-wang can you do qDebug()<<out.size();?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        V 1 Reply Last reply
        1
        • jsulmJ jsulm

          @victor-wang can you do qDebug()<<out.size();?

          V Offline
          V Offline
          victor wang
          wrote on last edited by
          #38

          @jsulm

          Yes, I can do that.
          this is my code here

          And it shows 0.
          Is that mean there is nothing in it?

          JKSHJ J.HilkJ 2 Replies Last reply
          0
          • V victor wang

            @jsulm

            Yes, I can do that.
            this is my code here

            And it shows 0.
            Is that mean there is nothing in it?

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by JKSH
            #39

            @victor-wang said in How can I get things from website:

            If it is how can i judge the signal and where do i have to add the function in?

            You make a signal-slot connection, using QObject::connect(). When the signal is emitted, the connected slot will run automatically.

            This is a core feature of Qt. I recommend you spend some time to do tutorials to understand how to use signals and slots.

            For the first of debugging and testing.
            I will get this on my browser. here

            OK, good. That means the server will give you text data.

            For the second one, i'm not quite sure what does that mean.

            Your code has QUrl("http://192.168.100/59/..."). Change this to QUrl("http://lists.qt-project.org/mailman/listinfo") for testing.

            For third one, what does"QNetworkRequest constructly correctly"mean?
            I thought i am using the library that Qt have already constructed.

            When you call QNetworkRequest(QUrl(...)); you are constructing a QNetworkRequest.

            Let's check that your QNetworkReply is what you expect. Put this in your replyFinished() slot:

            qDebug() << reply->isFinished();
            qDebug() << reply->error();
            qDebug() << reply->request();
            qDebug() << reply->url();
            qDebug() << reply->rawHeaderPair();
            

            For forth one, I'm sure i am on the same subnet because i can send this commend to my console

            wget http://192.168.100.59/PLMS/TestCheck.asp?LSN=201503003009&EmpId=we9999&CPID=OS&CPKey=95Z0000000AF
            

            And i will get the file and the content will show "updated ok".

            OK, good.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            V 2 Replies Last reply
            1
            • V victor wang

              @jsulm

              Yes, I can do that.
              this is my code here

              And it shows 0.
              Is that mean there is nothing in it?

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #40

              @victor-wang

              for your Xming copy/paste problem to windows, take a look to this topic:

              https://superuser.com/questions/440128/xming-clipboard-only-works-one-way

              That should enable you to poste your code as text for us and not as pictures.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • JKSHJ JKSH

                @victor-wang said in How can I get things from website:

                If it is how can i judge the signal and where do i have to add the function in?

                You make a signal-slot connection, using QObject::connect(). When the signal is emitted, the connected slot will run automatically.

                This is a core feature of Qt. I recommend you spend some time to do tutorials to understand how to use signals and slots.

                For the first of debugging and testing.
                I will get this on my browser. here

                OK, good. That means the server will give you text data.

                For the second one, i'm not quite sure what does that mean.

                Your code has QUrl("http://192.168.100/59/..."). Change this to QUrl("http://lists.qt-project.org/mailman/listinfo") for testing.

                For third one, what does"QNetworkRequest constructly correctly"mean?
                I thought i am using the library that Qt have already constructed.

                When you call QNetworkRequest(QUrl(...)); you are constructing a QNetworkRequest.

                Let's check that your QNetworkReply is what you expect. Put this in your replyFinished() slot:

                qDebug() << reply->isFinished();
                qDebug() << reply->error();
                qDebug() << reply->request();
                qDebug() << reply->url();
                qDebug() << reply->rawHeaderPair();
                

                For forth one, I'm sure i am on the same subnet because i can send this commend to my console

                wget http://192.168.100.59/PLMS/TestCheck.asp?LSN=201503003009&EmpId=we9999&CPID=OS&CPKey=95Z0000000AF
                

                And i will get the file and the content will show "updated ok".

                OK, good.

                V Offline
                V Offline
                victor wang
                wrote on last edited by
                #41

                @JKSH
                I add the qDebug in the replyFiniched() slot but i got some errors.
                Here

                Why is this happened?

                1 Reply Last reply
                0
                • JKSHJ JKSH

                  @victor-wang said in How can I get things from website:

                  If it is how can i judge the signal and where do i have to add the function in?

                  You make a signal-slot connection, using QObject::connect(). When the signal is emitted, the connected slot will run automatically.

                  This is a core feature of Qt. I recommend you spend some time to do tutorials to understand how to use signals and slots.

                  For the first of debugging and testing.
                  I will get this on my browser. here

                  OK, good. That means the server will give you text data.

                  For the second one, i'm not quite sure what does that mean.

                  Your code has QUrl("http://192.168.100/59/..."). Change this to QUrl("http://lists.qt-project.org/mailman/listinfo") for testing.

                  For third one, what does"QNetworkRequest constructly correctly"mean?
                  I thought i am using the library that Qt have already constructed.

                  When you call QNetworkRequest(QUrl(...)); you are constructing a QNetworkRequest.

                  Let's check that your QNetworkReply is what you expect. Put this in your replyFinished() slot:

                  qDebug() << reply->isFinished();
                  qDebug() << reply->error();
                  qDebug() << reply->request();
                  qDebug() << reply->url();
                  qDebug() << reply->rawHeaderPair();
                  

                  For forth one, I'm sure i am on the same subnet because i can send this commend to my console

                  wget http://192.168.100.59/PLMS/TestCheck.asp?LSN=201503003009&EmpId=we9999&CPID=OS&CPKey=95Z0000000AF
                  

                  And i will get the file and the content will show "updated ok".

                  OK, good.

                  V Offline
                  V Offline
                  victor wang
                  wrote on last edited by
                  #42

                  @JKSH
                  I have try to get from the Url which you gave me for test.
                  And i will get this information here.

                  So is that mean the code is not wrong?

                  JKSHJ 1 Reply Last reply
                  0
                  • V victor wang

                    @JKSH
                    I have try to get from the Url which you gave me for test.
                    And i will get this information here.

                    So is that mean the code is not wrong?

                    JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #43

                    @victor-wang said in How can I get things from website:

                    @JKSH
                    I have try to get from the Url which you gave me for test.
                    And i will get this information here.

                    So is that mean the code is not wrong?

                    Yes, your code is working correctly. Go to http://lists.qt-project.org/mailman/listinfo using your browser and view that web page's source (Ctrl+U in Google Chrome) -- it's the same as your last screenshot.

                    Your code is not wrong. Your device (192.168.100.59) probably returns data in a different way. Fix the errors below to investigate.

                    @victor-wang said in How can I get things from website:

                    @JKSH
                    I add the qDebug in the replyFiniched() slot but i got some errors.
                    Here

                    Oops, sorry... QNetworkRequest can't be printed through qDebug(). Just delete this line: qDebug() << reply->request();

                    The other one should be rawHeaderPairs(), not rawHeaderPair()

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    V 1 Reply Last reply
                    0
                    • JKSHJ JKSH

                      @victor-wang said in How can I get things from website:

                      @JKSH
                      I have try to get from the Url which you gave me for test.
                      And i will get this information here.

                      So is that mean the code is not wrong?

                      Yes, your code is working correctly. Go to http://lists.qt-project.org/mailman/listinfo using your browser and view that web page's source (Ctrl+U in Google Chrome) -- it's the same as your last screenshot.

                      Your code is not wrong. Your device (192.168.100.59) probably returns data in a different way. Fix the errors below to investigate.

                      @victor-wang said in How can I get things from website:

                      @JKSH
                      I add the qDebug in the replyFiniched() slot but i got some errors.
                      Here

                      Oops, sorry... QNetworkRequest can't be printed through qDebug(). Just delete this line: qDebug() << reply->request();

                      The other one should be rawHeaderPairs(), not rawHeaderPair()

                      V Offline
                      V Offline
                      victor wang
                      wrote on last edited by
                      #44

                      @JKSH

                      I had change the Url back to the original one.
                      And i get this

                      Is that mean i had receive something?
                      If it is why i didn't see any file that should get from the Url?

                      JKSHJ 1 Reply Last reply
                      0
                      • V victor wang

                        @JKSH

                        I had change the Url back to the original one.
                        And i get this

                        Is that mean i had receive something?
                        If it is why i didn't see any file that should get from the Url?

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by JKSH
                        #45

                        @victor-wang said in How can I get things from website:

                        @JKSH

                        I had change the Url back to the original one.
                        And i get this

                        Is that mean i had receive something?

                        Yes.

                        If it is why i didn't see any file that should get from the Url?

                        Because your code contains the wrong URL. You want LSN=201503003009, right?

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        V 3 Replies Last reply
                        0
                        • JKSHJ JKSH

                          @victor-wang said in How can I get things from website:

                          @JKSH

                          I had change the Url back to the original one.
                          And i get this

                          Is that mean i had receive something?

                          Yes.

                          If it is why i didn't see any file that should get from the Url?

                          Because your code contains the wrong URL. You want LSN=201503003009, right?

                          V Offline
                          V Offline
                          victor wang
                          wrote on last edited by
                          #46

                          @JKSH
                          Actually, if i connect success the URl i set will have the record.
                          But i just check it, there is nothing on it.
                          I don't know what to do now.

                          1 Reply Last reply
                          0
                          • JKSHJ JKSH

                            @victor-wang said in How can I get things from website:

                            @JKSH

                            I had change the Url back to the original one.
                            And i get this

                            Is that mean i had receive something?

                            Yes.

                            If it is why i didn't see any file that should get from the Url?

                            Because your code contains the wrong URL. You want LSN=201503003009, right?

                            V Offline
                            V Offline
                            victor wang
                            wrote on last edited by victor wang
                            #47

                            @JKSH
                            I solved the problem!
                            I 'm too stupid that i type the wrong vocabulary.
                            It's Empid not Empld in the Url.
                            Thank you so much for all your help!

                            1 Reply Last reply
                            0
                            • JKSHJ JKSH

                              @victor-wang said in How can I get things from website:

                              @JKSH

                              I had change the Url back to the original one.
                              And i get this

                              Is that mean i had receive something?

                              Yes.

                              If it is why i didn't see any file that should get from the Url?

                              Because your code contains the wrong URL. You want LSN=201503003009, right?

                              V Offline
                              V Offline
                              victor wang
                              wrote on last edited by
                              #48

                              @JKSH
                              There is another questions.

                              manager->get(QNetworkRequest(QUrl(http://www1.winmate/PLMS/TestCheck.asp?LSN=201503003009&Empid=we9999&CPID=OS&CPKey=95Z0000000AF)));
                              

                              what if the Empid is not the static one.
                              It will let the guest type there own id.
                              If i want to doing that how can i do it?

                              Can i type like this?

                              manager->get(QNetworkRequest(QUrl("http://www1.winmate/PLMS/TestCheck.asp?LSN=201503003009&"+"Empid="+ID"&CPID=OS&CPKey=95Z0000000AF")));
                              
                              jsulmJ 1 Reply Last reply
                              0
                              • V victor wang

                                @JKSH
                                There is another questions.

                                manager->get(QNetworkRequest(QUrl(http://www1.winmate/PLMS/TestCheck.asp?LSN=201503003009&Empid=we9999&CPID=OS&CPKey=95Z0000000AF)));
                                

                                what if the Empid is not the static one.
                                It will let the guest type there own id.
                                If i want to doing that how can i do it?

                                Can i type like this?

                                manager->get(QNetworkRequest(QUrl("http://www1.winmate/PLMS/TestCheck.asp?LSN=201503003009&"+"Empid="+ID"&CPID=OS&CPKey=95Z0000000AF")));
                                
                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by jsulm
                                #49

                                @victor-wang You can do it like this (Empid= can be just part of the first string - no need for +"Empid=").
                                Take a look at http://doc.qt.io/qt-5/qstring.html#arg

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                V 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @victor-wang You can do it like this (Empid= can be just part of the first string - no need for +"Empid=").
                                  Take a look at http://doc.qt.io/qt-5/qstring.html#arg

                                  V Offline
                                  V Offline
                                  victor wang
                                  wrote on last edited by
                                  #50

                                  @jsulm @JKSH
                                  I've got another question!
                                  I have 10 different Url wanna connect and get information down.
                                  And i'm using for() to do it.Here is my code.

                                  But it will crash and will not connect to the server.
                                  I assume that it because for() is doing too quick.
                                  So i add this inside the case

                                  reply->isFinished();
                                  

                                  But it will crash in the beginning.
                                  What else method can i try or what to fix in my code?
                                  Do i need to add the switch case into replyfinished() slot instead of connect?

                                  Please help!

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • V victor wang

                                    @jsulm @JKSH
                                    I've got another question!
                                    I have 10 different Url wanna connect and get information down.
                                    And i'm using for() to do it.Here is my code.

                                    But it will crash and will not connect to the server.
                                    I assume that it because for() is doing too quick.
                                    So i add this inside the case

                                    reply->isFinished();
                                    

                                    But it will crash in the beginning.
                                    What else method can i try or what to fix in my code?
                                    Do i need to add the switch case into replyfinished() slot instead of connect?

                                    Please help!

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by jsulm
                                    #51

                                    @victor-wang The problem isn't that for loop is too fast (how could it be too fast?).
                                    Starting with case one you have:

                                    reply->isFinished();
                                    

                                    How do you initialize reply? Most probably it is not initialized and you're dereferencing dangling pointer.
                                    Second question: why do you call isFinished() on reply? isFinished() is a getter method which you can use to check whether the reply is finished or not. But you do not use its return value, so the call is completely useless.
                                    In general: if your app is crashing you should first debug it before asking in a forum.
                                    So, please remove that useless reply->isFinished(); and debug your code to see where exactly it is crashing and why.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    V 1 Reply Last reply
                                    2
                                    • J.HilkJ Offline
                                      J.HilkJ Offline
                                      J.Hilk
                                      Moderators
                                      wrote on last edited by
                                      #52

                                      @victor-wang
                                      To add to @jsulm :

                                      make a make a proper Network function something along the line of:

                                      void getUrlData(QUrl url){
                                      //Do Stuff to call data from one URL
                                      }
                                      

                                      Place all your QUrls(10?) into a QList<QUrl>

                                      Now link the IsFinished Signal of your reply to Funktion to call the next URL request from your list.

                                      Dont forget to add a cancel condition, when you reach the end of your list.

                                      Now, start the download chain by calling the first element of your list by hand/button clicked.


                                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                      Q: What's that?
                                      A: It's blue light.
                                      Q: What does it do?
                                      A: It turns blue.

                                      V 1 Reply Last reply
                                      0
                                      • J.HilkJ J.Hilk

                                        @victor-wang
                                        To add to @jsulm :

                                        make a make a proper Network function something along the line of:

                                        void getUrlData(QUrl url){
                                        //Do Stuff to call data from one URL
                                        }
                                        

                                        Place all your QUrls(10?) into a QList<QUrl>

                                        Now link the IsFinished Signal of your reply to Funktion to call the next URL request from your list.

                                        Dont forget to add a cancel condition, when you reach the end of your list.

                                        Now, start the download chain by calling the first element of your list by hand/button clicked.

                                        V Offline
                                        V Offline
                                        victor wang
                                        wrote on last edited by victor wang
                                        #53

                                        @J.Hilk
                                        Is that mean that i have to connect IsFinished signal and getUrlData slot in the replyFinished() slot?
                                        What is that mean put in the QList?
                                        There is no IsFinished () signal for reply, just have finished signal.

                                        1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @victor-wang The problem isn't that for loop is too fast (how could it be too fast?).
                                          Starting with case one you have:

                                          reply->isFinished();
                                          

                                          How do you initialize reply? Most probably it is not initialized and you're dereferencing dangling pointer.
                                          Second question: why do you call isFinished() on reply? isFinished() is a getter method which you can use to check whether the reply is finished or not. But you do not use its return value, so the call is completely useless.
                                          In general: if your app is crashing you should first debug it before asking in a forum.
                                          So, please remove that useless reply->isFinished(); and debug your code to see where exactly it is crashing and why.

                                          V Offline
                                          V Offline
                                          victor wang
                                          wrote on last edited by
                                          #54

                                          @jsulm
                                          But how can i get 10 times of different Url.
                                          What should i connect signal?

                                          jsulmJ 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