Jump to content

Problem with a loop


ATR
 Share

Recommended Posts

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 :

<div id="activiteCheckbox">
                <p class="titlePopin">MATERIEL INFORMATIQUE </p>
                    <ul>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="26201200##vente de consommables et de mat&#233;riel informatique##MATERIEL INFORMATIQUE " type="checkbox">
                        <label for="chk26201200">vente de consommables et de mat&#233;riel informatique<span> - 461 r&#233;ponse(s)</span></label>
                        </li>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="26101400##r&#233;seaux informatiques##MATERIEL INFORMATIQUE " type="checkbox">
                        <label for="chk26101400">r&#233;seaux informatiques<span> - 62 r&#233;ponse(s)</span></label>
                        </li>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="38352200##location de mat&#233;riel informatique##MATERIEL INFORMATIQUE " type="checkbox">
                        <label for="chk38352200">location de mat&#233;riel informatique<span> - 22 r&#233;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&#233;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&#233;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&#233;ponse(s)</span></label>
                        </li>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="26101000##informatique : &#233;diteurs de logiciels, soci&#233;t&#233;s de services##SERVICE INFORMATIQUE" type="checkbox">
                        <label for="chk26101000">informatique : &#233;diteurs de logiciels, soci&#233;t&#233;s de services<span> - 1201 r&#233;ponse(s)</span></label>
                        </li>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="26100300##d&#233;pannage informatique##SERVICE INFORMATIQUE" type="checkbox">
                        <label for="chk26100300">d&#233;pannage informatique<span> - 347 r&#233;ponse(s)</span></label>
                        </li>
                    <li>
                        <input class="optional" name="rubriquesChoisiesAmbiguite" value="26100100##assistance &#224; domicile en informatique et Internet##SERVICE INFORMATIQUE" type="checkbox">
                        <label for="chk26100100">assistance &#224; domicile en informatique et Internet<span> - 137 r&#233;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&#233;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&#233;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&#233;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&#233;ponses contenant les mots recherch&#233;s" href="/trouverlesprofessionnels/suggerer.do?typeAction=suggerer&amp;idSuggestion=alphaMotIntituleDL&amp;typeSuggestion=SUG03&amp;isAmbigu=ACTIVITE&amp;idContext=1525686612&amp;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

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 by ATR
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...