Results 1 to 4 of 4

Thread: Reading data from a website without specified url

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Reading data from a website without specified url

    Hi!

    I play a videogame called Mu Online. The server I play offers a website where, by clicking in a link, I can get a list of currently active players and the server they are logged into (https://www.muonline.com.br/ , then click in the number after "Onlines" in the right menu).

    I'd like to create a light desktop app that would frequently (say 10s) monitors the active player table warning me when a given player is active via system tray icon.

    The problem is I don't have much experience with dealing with web information and what I have probably doesn't work here: I only have some experience with QNetworkAcessManager downloading asset data from Yahoo! Finances, something that was easily accesible via a configurable web url. The mentioned website above, though, doesn't provide a specific link to the online players table: you may notice that, when accessing the table, the url doesn't change.

    So how could I load this information from the website? I imagined that using QWebView I could archieve something, but I would still face the problem of reaching the online players table via QWebView.

    So how could I do this? Any help will be appreciated.
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reading data from a website without specified url

    The "Onlines" link shows it is a PHP script: https://www.muonline.com.br/onlines.php

    I am guessing that the javascript that gets executed by the PHP does a database lookup and presents the results you see.

    You could try executing this yourself by entering the URL, then parsing the HTML that gets returned. The list of users is in the "Onlines" table:

    Qt Code:
    1. <table summary="Onlines" class="tabela borda">
    2. <tr class="cor">
    3. <td class="titulo"><a href="/onlines.php?ordem=1">Personagem</a></td>
    4. <td class="titulo"><a href="/onlines.php?ordem=2">Classe</a></td>
    5. <td class="titulo"><a href="/onlines.php?ordem=3">Guild</a></td>
    6. <td class="titulo"><a href="/onlines.php?ordem=4">Sala</a></td>
    7. <td class="titulo"><a href="/onlines.php">Conectado desde</a></td>
    8. <td class="titulo"><a href="/onlines.php?ordem=6">VIP</a></td>
    9. </tr>
    10. <tr>
    11. <td>_Darkness_</td>
    12. <td>GM</td>
    13. <td>Dream_T</td>
    14. <td>VIP5</td>
    15. <td>25/06/2017 06:04:00 </td>
    16. <td><img src="imagens/vip_sim.gif" alt="Usu&aacute;rio VIP"></td>
    17. </tr>
    18. <tr class="cor">
    19. <td>LauraBuff</td>
    20. <td>ME</td>
    21. <td>Dream_T</td>
    22. <td>VIP5</td>
    23. <td>25/06/2017 06:05:00 </td>
    24. <td><img src="imagens/vip_sim.gif" alt="Usu&aacute;rio VIP"></td>
    25. </tr>
    26. <tr>
    27. <td>Jisty</td>
    28. <td>ME</td>
    29. <td>Valhalla</td>
    30. <td>VIP1</td>
    31. <td>26/06/2017 02:05:00 </td>
    32. <td><img src="imagens/vip_sim.gif" alt="Usu&aacute;rio VIP"></td>
    33. </tr>
    34.  
    35. ...
    36.  
    37. <tr>
    38. <td>HyperX</td>
    39. <td>MG</td>
    40. <td></td>
    41. <td>VIP4</td>
    42. <td>27/06/2017 16:06:00 </td>
    43. <td><img src="imagens/vip_sim.gif" alt="Usu&aacute;rio VIP"></td>
    44. </tr>
    45. </table>
    To copy to clipboard, switch view to plain text mode 

    In principle, it should not be much different from what you did with the Yahoo Finance lookup.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    Momergil (29th June 2017)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Reading data from a website without specified url

    Hello d_stranz,

    first thanks for the reply. I was able to 'get' the link your provided, but when I read the content, I get no data (and no errors are mentioned):

    Qt Code:
    1. void MainWindow::slotMainClock()
    2. {
    3. netAccMan->get(QNetworkRequest(QUrl("https://www.muonline.com.br/onlines.php")));
    4. }
    5.  
    6. void MainWindow::slotDownloadFinished(QNetworkReply* reply)
    7. {
    8. if (reply->error() != QNetworkReply::NoError)
    9. {
    10. qDebug() << "Error: " << reply->error();
    11. return;
    12. }
    13.  
    14. qDebug() << "Reading";
    15. qDebug() << reply->readAll();
    16. }
    To copy to clipboard, switch view to plain text mode 

    I couldn't figure out what's happening!
    May the Lord be with you. Always.

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reading data from a website without specified url

    I couldn't figure out what's happening!
    Sorry, can't help you either. Probably what happens in the browser is different from what occurs with your QNetworkRequest. As I remember, the capture of your web page also had references to a couple of javascript files - these may be doing client-side formatting of the PHP output, as described here.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. The following user says thank you to d_stranz for this useful post:

    Momergil (29th June 2017)

Similar Threads

  1. Reading UDP data properly
    By ankit.1g@gmail.com in forum Newbie
    Replies: 3
    Last Post: 16th February 2016, 12:34
  2. read data from website
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 4
    Last Post: 27th June 2013, 11:32
  3. Replies: 0
    Last Post: 10th September 2011, 13:38
  4. Reading data from socket
    By ComaWhite in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2008, 18:22
  5. Reading binary data
    By vermarajeev in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 09:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.