PDA

View Full Version : how to retrieve data from a html file using QWebView QT



cruzo
7th April 2015, 22:24
Hello guys ,

i am a beginner in QT (C++), i need to retrieve data from a html page and send it in a sql database . The data i am talking about is between html tags (in red) as shown below . I know how to send data in a database but i don't know how to retrieve the data from this in C++ , please help me as this is only a small part of the whole html page from which i am supposed to retrieve data . I really need a help and knowing you all are pro in C++ Qt i know you will be able to help me .

Before posting this "help me" message i searched on the net and found some kind of similar cases as mine but as i am new i didn't understand the replies and didn't know how to adapt them wih my situation, please help i really need to do this as it is a school project.

:crying:

<body>
<div id="cross_rates_container" style="clear:both"><table id="cross_rate_1" border=0 class="ftq_4 ftq_5_1" style="width:497px;margin:0px;padding:0px;" cellspacing=0 cellpadding=0 id="curr_table"><tr class="arial_11_white_b ftq_5"><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap><nobr>Nom</nobr></td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>Achat</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>Vente</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>Cours</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>Ouverture</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>+ Haut</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>+ Bas</td><td class="ftqw2 ftqh ftqa11wb ftqac" nowrap>Var %</td></tr><tr id="pair_1" class="arial_11 ftqtr1" style="background-color:#F6F6F6;"><td class="ftqbb ftqw1 ftqrl" nowrap="nowrap"><nobr><span class="vertical arrow_red_down" title="_cross_rates_last_tick" style="margin-right:5px;">&nbsp;</span><span class="ftqa11bb arial_11_b">USD/JPY</span></td></nobr><td class="ftqbb ftqw2 pid-3-bid" style="direction:ltr;">119,13</td><td class="ftqbb ftqw2 pid-3-ask" style="direction:ltr;">119,15</td><td class="ftqbb ftqw2 pid-3-last" style="direction:ltr;">119,14</td><td class="ftqbb ftqw2" style="direction:ltr;">119,19</td><td class="ftqbb ftqw2 pid-3-high" style="direction:ltr;">119,50</td><td class="ftqbb ftqw2 pid-3-low" style="direction:ltr;">118,94</td>
</body>
</html>

ChrisW67
7th April 2015, 23:28
In short, you:

Load the web page in QWebView or QWebPage,
Indentify the mainFrame() of the page, and
Use QWebFrame::findFirstElement() or QWebFrame::findAllElements() to identify the parts of the document you need, or
Get the documentElement() and use the functions of QWebElement to navigate the document.