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 access data from web
Servers for Qt installer are currently down

How to access data from web

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 1.3k 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.
  • A Offline
    A Offline
    Albert Huert
    wrote on 3 Jan 2020, 21:01 last edited by
    #1

    I am doing a program to calculate my electric power payment, for this I need to obtain the cost per kWh from the official website of the company that offers the service. I need to enter my username and password to see the cost of kWh in my area. From what I have investigated, I understand that the page file is downloaded in xml format and with a function that file is read to find the required data. How do I connect to your website and get the cost of kWh data?
    Thanks for help me.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 4 Jan 2020, 00:53 last edited by
      #2

      Hi
      It depends on how the site logs in etc but normally you can use
      QNetworkAccessManager
      https://doc.qt.io/qt-5/qnetworkaccessmanager.html

      Not complete code!
      And it might not be called username and password for your site.
      You have to check the code for it in a browser or other tool.

      QUrl serviceUrl = QUrl("http://test.com/login.php");
      QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
      connect(networkManager, SIGNAL(finished(QNetworkReply*)),
              this, SLOT(serviceRequestFinished(QNetworkReply*)));
      
      QUrlQuery postData;
      postData.addQueryItem("username", "my_username");
      postData.addQueryItem("password", "my_password");
      

      https://forum.qt.io/topic/54747/login-to-a-website

      Do note QNetworkAccessManager is async and you must use the signals to know when its
      finished to login and then try to download the file.

      https://stackoverflow.com/questions/30010540/automate-https-login

      Also if its HTTPS, you might need to download OpenSSL libs to use with your app.

      Also, if the site redirects you, you might also get issues/ need to handle that.
      https://stackoverflow.com/questions/23479362/login-to-website-using-qt

      1 Reply Last reply
      3
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 4 Jan 2020, 05:48 last edited by
        #3

        Sounds like your power company offers a web services interface. There are several flavors, but you'll need to figure out which type your company provides and then use a proper web services API to access their site. It's been my experience that trying to brute force hack the interface doesn't work. So to be clear, this is a level above QNetworkManager, instead using a proper web services API, as determined by which flavor the service provides.

        A 1 Reply Last reply 4 Jan 2020, 19:08
        4
        • K Kent-Dorfman
          4 Jan 2020, 05:48

          Sounds like your power company offers a web services interface. There are several flavors, but you'll need to figure out which type your company provides and then use a proper web services API to access their site. It's been my experience that trying to brute force hack the interface doesn't work. So to be clear, this is a level above QNetworkManager, instead using a proper web services API, as determined by which flavor the service provides.

          A Offline
          A Offline
          Albert Huert
          wrote on 4 Jan 2020, 19:08 last edited by
          #4

          @Kent-Dorfman Hi, I think I explained badly, it's not about hacking a website. What I want to do is enter through a program in Qt to the website of the company that gives me the electric power service to check my kWh consumption and what I have to pay. I can do this through a web browser by logging into my account (username + password) and viewing the kWh and payment data in the web browser or I can download an xml file that has this data. What I want is for the program in Qt to enter my password and user and download the xml and me of the kWh to calculate my payment.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 4 Jan 2020, 19:38 last edited by
            #5

            Hi,

            That's what is talked about. From my understanding with your second description is that you seem to want to automate a web site usage. What other people proposed here was about using an API provided by your electricity company. If such an API is available, it would likely be easier to implement your application.

            Otherwise it seems you want to implement something like selenium, isn't it ?

            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
            • A Offline
              A Offline
              adomanim
              Banned
              wrote on 7 Jan 2020, 15:36 last edited by adomanim 1 Oct 2020, 14:07
              #6
              This post is deleted!
              1 Reply Last reply
              0

              1/6

              3 Jan 2020, 21:01

              • Login

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