ATR Posted October 12, 2011 Share Posted October 12, 2011 Hi all, I have a problem in my loop. I want to recover text in a specific order from a HTML code. My HTML code : expandcollapse popup<div id="activiteCheckbox"> <p class="titlePopin">MATERIEL INFORMATIQUE </p> <ul> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26201200##vente de consommables et de matériel informatique##MATERIEL INFORMATIQUE " type="checkbox"> <label for="chk26201200">vente de consommables et de matériel informatique<span> - 461 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26101400##réseaux informatiques##MATERIEL INFORMATIQUE " type="checkbox"> <label for="chk26101400">réseaux informatiques<span> - 62 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="38352200##location de matériel informatique##MATERIEL INFORMATIQUE " type="checkbox"> <label for="chk38352200">location de matériel informatique<span> - 22 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26200100##constructeurs informatique##MATERIEL INFORMATIQUE " type="checkbox"> <label for="chk26200100">constructeurs informatique<span> - 13 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="00850524##micro-informatique##MATERIEL INFORMATIQUE " type="checkbox"> <label for="chk00850524">micro-informatique<span> - 1 réponse(s)</span></label> </li> </ul> <p class="titlePopin">SERVICE INFORMATIQUE</p> <ul> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="00050220##informatique : conseils, services, maintenance##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk00050220">informatique : conseils, services, maintenance<span> - 1608 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26101000##informatique : éditeurs de logiciels, sociétés de services##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk26101000">informatique : éditeurs de logiciels, sociétés de services<span> - 1201 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26100300##dépannage informatique##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk26100300">dépannage informatique<span> - 347 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26100100##assistance à domicile en informatique et Internet##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk26100100">assistance à domicile en informatique et Internet<span> - 137 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="00050230##formation informatique##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk00050230">formation informatique<span> - 20 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="00850522##informatique : assistance technique utilisateurs##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk00850522">informatique : assistance technique utilisateurs<span> - 12 réponse(s)</span></label> </li> <li> <input class="optional" name="rubriquesChoisiesAmbiguite" value="26100800##informatique : conseils, services, formation##SERVICE INFORMATIQUE" type="checkbox"> <label for="chk26100800">informatique : conseils, services, formation<span> - 2 réponse(s)</span></label> </li> </ul> <h2>Par "Nom"</h2> <ul> <li> <a class="JS_PJ aTag_INFO idTag_VOIR-AUSSI" title="Voir les réponses contenant les mots recherchés" href="/trouverlesprofessionnels/suggerer.do?typeAction=suggerer&idSuggestion=alphaMotIntituleDL&typeSuggestion=SUG03&isAmbigu=ACTIVITE&idContext=1525686612&portail=SEO_PJ"><strong> Les professionnels dont le nom contient Informatique</strong> </a></li> </ul> </div> And I want : MATERIEL INFORMATIQUE vente de consommables et de matériel informatique réseaux informatiques location de matériel informatique constructeurs informatique micro-informatique SERVICE INFORMATIQUE informatique : conseils, services, maintenance informatique : éditeurs de logiciels, sociétés de services dépannage informatique assistance à domicile en informatique et Internet formation informatique informatique : assistance technique utilisateurs informatique : conseils, services, formation My actual script : $oInputs = _IETagNameGetCollection ($IE, "div") For $oInput In $oInputs If StringInStr($oInput.id, "activiteCheckbox") Then $oInputs_LI = _IETagNameGetCollection ($IE, "li") $oInputs_P = _IETagNameGetCollection ($IE, "p") For $oInput_P In $oInputs_P $RubriquePrincipale = StringRegExp($oInput_P.outerhtml, '(?s)titlePopin">(.*?)</p>', 1) If @error = 0 Then ConsoleWrite($RubriquePrincipale[0] & @CRLF) EndIf Next For $oInput_LI In $oInputs_LI $SousRubrique_associee = StringRegExp($oInput_LI.outerhtml, '(?s)label for="chk.*?">(\D*)<span>\s*.*?réponse', 1) If @error = 0 Then ConsoleWrite($SousRubrique_associee[0] & @CRLF) EndIf Next EndIf Next Wend Link to comment Share on other sites More sharing options...
JohnOne Posted October 12, 2011 Share Posted October 12, 2011 Fix your post pal, its weird. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ATR Posted October 13, 2011 Author Share Posted October 13, 2011 (edited) Fix your post pal, its weird. $oInputs = _IETagNameGetCollection ($IE, "div") For $oInput In $oInputs If StringInStr($oInput.id, "activiteCheckbox") Then $oInputs_LI = _IETagNameGetCollection ($IE, "li") $oInputs_P = _IETagNameGetCollection ($IE, "p") For $oInput_P In $oInputs_P $RubriquePrincipale = StringRegExp($oInput_P.outerhtml, '(?s)titlePopin">(.*?)</p>', 1) If @error = 0 Then ConsoleWrite($RubriquePrincipale[0] & @CRLF) EndIf Next For $oInput_LI In $oInputs_LI $SousRubrique_associee = StringRegExp($oInput_LI.outerhtml, '(?s)label for="chk.*?">(\D*)<span>\s*.*?réponse', 1) If @error = 0 Then ConsoleWrite($SousRubrique_associee[0] & @CRLF) EndIf Next EndIf Next Edited October 13, 2011 by ATR Link to comment Share on other sites More sharing options...
ATR Posted October 13, 2011 Author Share Posted October 13, 2011 Fix your post pal, its weird. $oInputs = _IETagNameGetCollection ($IE, "div") For $oInput In $oInputs If StringInStr($oInput.id, "activiteCheckbox") Then $oInputs_LI = _IETagNameGetCollection ($IE, "li") $oInputs_P = _IETagNameGetCollection ($IE, "p") For $oInput_P In $oInputs_P $RubriquePrincipale = StringRegExp($oInput_P.outerhtml, '(?s)titlePopin">(.*?)</p>', 1) If @error = 0 Then ConsoleWrite($RubriquePrincipale[0] & @CRLF) EndIf Next For $oInput_LI In $oInputs_LI $SousRubrique_associee = StringRegExp($oInput_LI.outerhtml, '(?s)label for="chk.*?">(\D*)<span>\s*.*?réponse', 1) If @error = 0 Then ConsoleWrite($SousRubrique_associee[0] & @CRLF) EndIf Next EndIf Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now