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 36.0k 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.
  • jsulmJ jsulm

    @victor-wang What do you mean? You do the same: connect finished() signal to your slot. In that slot (which you already have) you can get the URL from the response to know for which URL this response is coming.
    QNetworkAccessManager can handle many requests in parallel - no need to do something special.

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

    @jsulm
    https://forum.qt.io/topic/77186/how-can-i-get-10-different-url

    This is my new topic and i had describe it.
    I will describe here for you again.
    Please help.

    i will send this commend for 10 times in the different CPID.

    CPID="TOUCH";
    URL="http://192.168.100.59/OLMS/TeskCheck.asp?LSN="+LSN+"&Empid="+EMPID+"&CPID="+CPID+"&CPKey=XXX";
    manager->get(QNetworkRequest(QUrl(URL)));
    

    But during the process it will return 500 instead of 200 and can't connect to the Url for the few times.
    How can i solve this problem?

    jsulmJ 1 Reply Last reply
    0
    • V victor wang

      @jsulm
      https://forum.qt.io/topic/77186/how-can-i-get-10-different-url

      This is my new topic and i had describe it.
      I will describe here for you again.
      Please help.

      i will send this commend for 10 times in the different CPID.

      CPID="TOUCH";
      URL="http://192.168.100.59/OLMS/TeskCheck.asp?LSN="+LSN+"&Empid="+EMPID+"&CPID="+CPID+"&CPKey=XXX";
      manager->get(QNetworkRequest(QUrl(URL)));
      

      But during the process it will return 500 instead of 200 and can't connect to the Url for the few times.
      How can i solve this problem?

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

      @victor-wang HTTP 500 status code means: "500 Internal Server Error".
      You should check using a browser whether these URLs are working.

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

      V 1 Reply Last reply
      0
      • jsulmJ jsulm

        @victor-wang HTTP 500 status code means: "500 Internal Server Error".
        You should check using a browser whether these URLs are working.

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

        @jsulm
        I'm sure it is worked because if i have just connect that one, it will work correctly.
        But if it's in the loop and is not at the first one, sometimes will failed but sometime will success.
        So that's why i doubt that because it sending too quick that the server cannot catch it well.

        jsulmJ 1 Reply Last reply
        0
        • V victor wang

          @jsulm
          I'm sure it is worked because if i have just connect that one, it will work correctly.
          But if it's in the loop and is not at the first one, sometimes will failed but sometime will success.
          So that's why i doubt that because it sending too quick that the server cannot catch it well.

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

          @victor-wang Then it is an issue with your server - it is either too slow or it cannot handle concurrent requests.

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

          V 1 Reply Last reply
          0
          • jsulmJ jsulm

            @victor-wang Then it is an issue with your server - it is either too slow or it cannot handle concurrent requests.

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

            @jsulm
            Did you see my code that i had just gave you?

            I'm not quite sure that is the server issue.
            I doubt that my code is not really perfect.
            Could you help me see the code?

            jsulmJ 1 Reply Last reply
            0
            • V victor wang

              @jsulm
              Did you see my code that i had just gave you?

              I'm not quite sure that is the server issue.
              I doubt that my code is not really perfect.
              Could you help me see the code?

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

              @victor-wang Your do..while loop is an infinite loop if you get a response != 200
              It does not make sense as a reply is either 200 or not: it will not become 200 if it wasn't before by some magic, so remove that loop.
              As I said 500 means internal server error. You get a connection but the server fails to do what it is expected to do and sends 500 back.
              If you want to slow down your requests you can use QTimer.

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

              V 1 Reply Last reply
              0
              • jsulmJ jsulm

                @victor-wang Your do..while loop is an infinite loop if you get a response != 200
                It does not make sense as a reply is either 200 or not: it will not become 200 if it wasn't before by some magic, so remove that loop.
                As I said 500 means internal server error. You get a connection but the server fails to do what it is expected to do and sends 500 back.
                If you want to slow down your requests you can use QTimer.

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

                @jsulm

                If i change my code like this.

                It will failed for a few times.

                I'm trying to solve this kind of problem

                jsulmJ 2 Replies Last reply
                0
                • V victor wang

                  @jsulm

                  If i change my code like this.

                  It will failed for a few times.

                  I'm trying to solve this kind of problem

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

                  @victor-wang What does fail mean? Do you get 500?

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

                  1 Reply Last reply
                  0
                  • V victor wang

                    @jsulm

                    If i change my code like this.

                    It will failed for a few times.

                    I'm trying to solve this kind of problem

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

                    @victor-wang If you do not want to send all request in parallel you can do it one after another.

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

                    V 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @victor-wang If you do not want to send all request in parallel you can do it one after another.

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

                      @jsulm
                      Yes, it will show 500.

                      how to do that?
                      Could you teach me?

                      Or can i do 5 times and another 5 times.

                      jsulmJ 1 Reply Last reply
                      0
                      • V victor wang

                        @jsulm
                        Yes, it will show 500.

                        how to do that?
                        Could you teach me?

                        Or can i do 5 times and another 5 times.

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

                        @victor-wang Put all URLs you want to get in a list.
                        Write a method which takes next URL from that list and sends a request.
                        Call this method in your button slot.
                        In the finished() slot you call this method again after handling current response if the list is not empty.

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

                        V 1 Reply Last reply
                        2
                        • jsulmJ jsulm

                          @victor-wang Put all URLs you want to get in a list.
                          Write a method which takes next URL from that list and sends a request.
                          Call this method in your button slot.
                          In the finished() slot you call this method again after handling current response if the list is not empty.

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

                          @jsulm
                          Sorry it is too abstract for me,
                          Did you have an example?

                          jsulmJ 1 Reply Last reply
                          0
                          • V victor wang

                            @jsulm
                            Sorry it is too abstract for me,
                            Did you have an example?

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

                            @victor-wang No, I don't have an example.
                            What is abstract here? I gave you a quite complete description.
                            What exactly is not clear?

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

                            V 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @victor-wang No, I don't have an example.
                              What is abstract here? I gave you a quite complete description.
                              What exactly is not clear?

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

                              @jsulm
                              I don't know how to do it in the list and give a request.
                              I assume that i had a method function called getUrl();
                              And i will called it in the button.
                              When the replyFinished() slot is called from button.
                              Then i will call getUrl() again in the replyFinished() slot.

                              I this what you mean?

                              jsulmJ 1 Reply Last reply
                              0
                              • V victor wang

                                @jsulm
                                I don't know how to do it in the list and give a request.
                                I assume that i had a method function called getUrl();
                                And i will called it in the button.
                                When the replyFinished() slot is called from button.
                                Then i will call getUrl() again in the replyFinished() slot.

                                I this what you mean?

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

                                @victor-wang

                                //In your class:
                                QList<QString> list;
                                
                                // In your button slot
                                list << "URL1" << "URL2"<<...;
                                sendNextRequest();
                                
                                void sendNextRequest()
                                {
                                    QString url = list.first();
                                    list.removeFirst();
                                    // Send request
                                }
                                
                                // In your finished() slot
                                // Handle current request
                                ...
                                if (list.size() > 0)
                                    sendNextRequest();
                                

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

                                V 1 Reply Last reply
                                1
                                • jsulmJ jsulm

                                  @victor-wang

                                  //In your class:
                                  QList<QString> list;
                                  
                                  // In your button slot
                                  list << "URL1" << "URL2"<<...;
                                  sendNextRequest();
                                  
                                  void sendNextRequest()
                                  {
                                      QString url = list.first();
                                      list.removeFirst();
                                      // Send request
                                  }
                                  
                                  // In your finished() slot
                                  // Handle current request
                                  ...
                                  if (list.size() > 0)
                                      sendNextRequest();
                                  
                                  V Offline
                                  V Offline
                                  victor wang
                                  wrote on last edited by
                                  #71

                                  @jsulm

                                  Is the void sendNextRequest() able to put in the button slot?

                                  When do i call my

                                  manager->get(QNetworkRequest(QUrl(url)));
                                  

                                  Is the finished() slot same as my replyFinished() slot?

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • V victor wang

                                    @jsulm

                                    Is the void sendNextRequest() able to put in the button slot?

                                    When do i call my

                                    manager->get(QNetworkRequest(QUrl(url)));
                                    

                                    Is the finished() slot same as my replyFinished() slot?

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

                                    @victor-wang Yes, you call void sendNextRequest() in the button slot as any other method.
                                    You call

                                    manager->get(QNetworkRequest(QUrl(url)));
                                    

                                    in void sendNextRequest() as I already said.
                                    finished() signal is same except for these two lines (as I already said):

                                    if (list.size() > 0)
                                        sendNextRequest();
                                    

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

                                    V 1 Reply Last reply
                                    1
                                    • jsulmJ jsulm

                                      @victor-wang Yes, you call void sendNextRequest() in the button slot as any other method.
                                      You call

                                      manager->get(QNetworkRequest(QUrl(url)));
                                      

                                      in void sendNextRequest() as I already said.
                                      finished() signal is same except for these two lines (as I already said):

                                      if (list.size() > 0)
                                          sendNextRequest();
                                      
                                      V Offline
                                      V Offline
                                      victor wang
                                      wrote on last edited by
                                      #73

                                      @jsulm

                                      Thank you i had solve the problem
                                      Thank you so much!!!!

                                      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