REGEX complexe dans code source html
Posté : 22 mars 2010, 16:38
Bonjour,
Je dois chercher des informations dans une page contenant le code source suivant :
Je dois dans un premier temps récupérer la dernière balise <tr> contenant ERROR </tr> puis extraire les informations contenues entre les balises.
Et la je ne sais comment m'y prentre, est ce que je dois supprimer toutes les balises et les remplacer par des ; par ex pour apres pouvoir faciliter le traitement ou autre. Je galère depuis 2 jours si qqn pouvait me donner une piste car la je suis perdu.
Je vous remercie par avance
Je dois chercher des informations dans une page contenant le code source suivant :
Code : Tout sélectionner
<tbody><tr>
<td class="datagrid_red_cell" nowrap="nowrap"> 536848 </td><td class="datagrid_red_cell" nowrap="nowrap"> 536848 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 03:34:21 </td><td class="datagrid_red_cell" nowrap="nowrap"> 03:34:21 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-21.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-21.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> OK </td><td class="datagrid_red_cell" nowrap="nowrap"> NOK </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=57774&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=54327&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=57774&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=54327&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> </td></tr>
<tr>
<td class="datagrid_red_cell" nowrap="nowrap"> 536902 </td><td class="datagrid_red_cell" nowrap="nowrap"> 536902 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 03:34:21 </td><td class="datagrid_red_cell" nowrap="nowrap"> 03:34:21 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-21.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-21.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> ERREUR </td><td class="datagrid_red_cell" nowrap="nowrap"> ERREUR </td><td class="datagrid_red_cell" nowrap="nowrap"> ERROR </td><td class="datagrid_red_cell" nowrap="nowrap"> NOK </td><td class="datagrid_red_cell" nowrap="nowrap"> Appli : SETUP / User error : SN9 / Internal error : / Details : _stepEnd : Setup._setCardlessCak;mac=00043025E0AF </td><td class="datagrid_red_cell" nowrap="nowrap"> Appli : SETUP / User error : SN9 / Internal error : / Details : _stepEnd : Setup._setCardlessCak;mac=00043025E0AF </td><td class="datagrid_red_cell" nowrap="nowrap"> </td></tr>
<tr>
<td class="datagrid_red_cell" nowrap="nowrap"> 898590 </td><td class="datagrid_red_cell" nowrap="nowrap"> 898590 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:01:28 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:01:28 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-23.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-23.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> OK </td><td class="datagrid_red_cell" nowrap="nowrap"> NOK </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=59308&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=56135&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=59308&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=56135&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> </td></tr>
<tr>
<td class="datagrid_red_cell" nowrap="nowrap"> 898640 </td><td class="datagrid_red_cell" nowrap="nowrap"> 898640 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:01:28 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:01:28 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-23.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-23.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> ERREUR </td><td class="datagrid_red_cell" nowrap="nowrap"> ERREUR </td><td class="datagrid_red_cell" nowrap="nowrap"> ERROR </td><td class="datagrid_red_cell" nowrap="nowrap"> NOK </td><td class="datagrid_red_cell" nowrap="nowrap"> Appli : SETUP / User error : SN9 / Internal error : / Details : _stepEnd : Setup._setCardlessCak;mac=00043025E0AF </td><td class="datagrid_red_cell" nowrap="nowrap"> Appli : SETUP / User error : SN9 / Internal error : / Details : _stepEnd : Setup._setCardlessCak;mac=00043025E0AF </td><td class="datagrid_red_cell" nowrap="nowrap"> </td></tr>
<tr>
<td class="datagrid_red_cell" nowrap="nowrap"> 1262459 </td><td class="datagrid_red_cell" nowrap="nowrap"> 1262459 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 2010-03-20 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:32:11 </td><td class="datagrid_red_cell" nowrap="nowrap"> 04:32:11 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> 10.23.8.213 </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-15.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> frontal-15.tv </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> STATUS </td><td class="datagrid_red_cell" nowrap="nowrap"> OK </td><td class="datagrid_red_cell" nowrap="nowrap"> NOK </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=60761&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=57943&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> ?pkg=stats&fct=qostv&op=neuf&roomId=1&mac=00043025E0AF&fw=4.7.44&rxPackets=60761&rxErrors=0&intRxErrors=0&rtpPackets=0&joinCount=0&joinHist=0_0_0_0_0_0_0_0_0_0_0_0&hw=n10-3-15&uptime=57943&intSpeed=0& </td><td class="datagrid_red_cell" nowrap="nowrap"> </td></tr>
Et la je ne sais comment m'y prentre, est ce que je dois supprimer toutes les balises et les remplacer par des ; par ex pour apres pouvoir faciliter le traitement ou autre. Je galère depuis 2 jours si qqn pouvait me donner une piste car la je suis perdu.
Je vous remercie par avance