Code : Tout sélectionner
#include <MsgBoxConstants.au3>
#include <IE.au3>
#include <debug.au3>
Enum $READYSTATE_UNINITIALIZED, _ ; 0
$READYSTATE_LOADING, _ ; 1
$READYSTATE_LOADED, _ ; 2
$READYSTATE_INTERACTIVE, _ ; 3
$READYSTATE_COMPLETE _ ; 4
_DebugSetup(Default, True, 2)
_DebugCOMError(1)
For $i = 1 To 10
_DebugOut(">Itération : " & $i)
_DebugOut("_IECreate()...")
Local $oIE = _IECreate("http://www.pagespro.com/resultats/transport-et-mise-en-oeuvre-du-beton", 0, 1, False)
If @error Then MsgBox($MB_ICONERROR, Default, StringFormat("%s\r\n@error : %s\r\n@extended : %s", @ScriptLineNumber, @error, @extended))
_DebugReportVar("$oIE", $oIE, True)
While 1
_DebugReportVar("$oIE.ReadyState", $oIE.ReadyState, True)
_DebugReportVar("$oIE.Busy", $oIE.Busy, True)
If Not $oIE.Busy And $oIE.ReadyState >= $READYSTATE_LOADED Then
_DebugReportVar("$oIE.document.ReadyState", $oIE.document.ReadyState, True)
; Quand document.ReadyState = "interactive", le document est parsé donc à ce stade,
; il est maintenant possible de récupérer des éléments.
If $oIE.document.ReadyState = "interactive" Or $oIE.document.ReadyState = "complete" Then ExitLoop
EndIf
Sleep(2000)
WEnd
$oSpans = _IETagNameGetCollection($oIE, "span")
If @error Then MsgBox($MB_ICONERROR, Default, StringFormat("%s\r\n@error : %s\r\n@extended : %s", @ScriptLineNumber, @error, @extended))
_DebugOut("-->Nombre d'éléments SPAN retournés : " & @extended)
_DebugReportVar("$oSpans", $oSpans, True)
Local $txt
For $oSpan in $oSpans
If $oSpan.getattribute("itemprop") = "name" Then $txt &= $oSpan.innertext & @crlf
Next
_DebugReportVar("$oIE", $oIE, True)
_IEQuit($oIE)
If @error Then MsgBox($MB_ICONERROR, Default, StringFormat("%s\r\n@error : %s\r\n@extended : %s", @ScriptLineNumber, @error, @extended))
_DebugReportVar("$oIE", $oIE, True)
Next