PDA

View Full Version : How to access data from web



Eduardo Huerta
3rd January 2020, 04:14
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. How do I connect to your website and get the cost of kWh data?
Thanks for help me.

ChrisW67
3rd January 2020, 06:47
Fetch the data with these main classes: QNetworkAccessManager
QNetworkRequest
QNetworkReply
Demonstrated in this example: HTTP example (https://doc.qt.io/qt-5/qtnetwork-http-example.html)

Then you have to parse the response (maybe HTML, maybe something else) to find the magic number you seek.

Eduardo Huerta
3rd January 2020, 21:10
Hello, thanks for answering.
I have found information on the subject and I have understood that the recommended format is XML, the file is downloaded and read with an XML parser. Do you know if you can do this with Qt? How do I put my username and password to the page through my program to access my user data on the official website of the company?
Thanks a lot.

d_stranz
3rd January 2020, 23:45
The answers are going to depend on the specific protocol the company's site uses for these kinds of requests. You probably need to ask someone in the company's IT department about this, or search their web site for information. Every site will be different.

It is unlikely that their protocol would involve sending your username and password in clear text. That would be a pretty bad security hole.

Qt has a complete set of classes for handling XML (https://doc.qt.io/qt-5/qtxml-index.html), if that is the way your company provides data when you send a query.