tout d'abord, voici le script :
;*****************************************
;PMU.au3 by Romain
;Créé avec ISN AutoIt Studio v. 0.99 BETA
;*****************************************
#include <IE.au3>
_IEErrorHandlerRegister(_User_ErrFunc)
Run("notepad.exe")
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
$oIE = _IECreate()
for $jour = 10 to 31
_IENavigate($oIE, "http://www.canalturf.com/courses_archives.php?date=2017-01-" & $jour)
;~ On parcourt tous les a, dont la classe est btn btn-sm btn-primary ==> les pronos
$tags = $oIE.document.GetElementsByTagName("a")
For $tag in $tags
$class_value = $tag.className
If $class_value = "btn btn-sm btn-primary" Then
$url = $tag.getAttribute("href")
$oIE_prono = _IECreate()
_IENavigate($oIE_prono, $url)
sleep(250)
$tagsProno = $oIE_prono.document.GetElementsByTagName("td")
$prono = $url
for $tagProno in $tagsProno
$wv = $tagProno.getAttribute("width")
if $wv = 30 Then
$prono = $prono & "," & _IEPropertyGet($tagProno,"innerText")
EndIf
Next
sleep(250)
WinActivate($hWnd)
sleep(200)
Send($prono)
Send("{ENTER}")
Sleep(250)
_IEQuit($oIE_prono)
EndIf
Next
next
Func _User_ErrFunc($oError)
; Do anything here.
ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc
;PMU.au3 by Romain
;Créé avec ISN AutoIt Studio v. 0.99 BETA
;*****************************************
#include <IE.au3>
_IEErrorHandlerRegister(_User_ErrFunc)
Run("notepad.exe")
Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
$oIE = _IECreate()
for $jour = 10 to 31
_IENavigate($oIE, "http://www.canalturf.com/courses_archives.php?date=2017-01-" & $jour)
;~ On parcourt tous les a, dont la classe est btn btn-sm btn-primary ==> les pronos
$tags = $oIE.document.GetElementsByTagName("a")
For $tag in $tags
$class_value = $tag.className
If $class_value = "btn btn-sm btn-primary" Then
$url = $tag.getAttribute("href")
$oIE_prono = _IECreate()
_IENavigate($oIE_prono, $url)
sleep(250)
$tagsProno = $oIE_prono.document.GetElementsByTagName("td")
$prono = $url
for $tagProno in $tagsProno
$wv = $tagProno.getAttribute("width")
if $wv = 30 Then
$prono = $prono & "," & _IEPropertyGet($tagProno,"innerText")
EndIf
Next
sleep(250)
WinActivate($hWnd)
sleep(200)
Send($prono)
Send("{ENTER}")
Sleep(250)
_IEQuit($oIE_prono)
EndIf
Next
next
Func _User_ErrFunc($oError)
; Do anything here.
ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc
Explication du script : après m'être rendu sur la page des pronos du 01.01.2017, je parcours tous les liens de la page.
Ceux dont la classe est btn btn-sm btn-primary sont les liens vers les pronostics.
Je boucle sur ces liens.
Dans la page d'un lien, je récupère ensuite les 3 tableaux du bas de page (le n°de cheval).
Puis j'écris dans notepad.
Au départ, tout se passe parfaitement bien et d'un coup, le script n'arrive plus récupérer les chevaux.
EDIT : et finit par planter complètement.
En loggant les erreurs :
Code : Tout sélectionner
C:\Users\Romain\Documents\ISN AutoIt Studio\Projects\PMU\PMU.au3 (28) : ==> COM Error intercepted !
err.number is: 0x80020008
err.windescription: Type de variable incorrect.
err.description is:
err.source is:
err.helpfile is:
err.helpcontext is:
err.lastdllerror is: 0
err.scriptline is: 28
err.retcode is: 0x00000000
C:\Users\Romain\Documents\ISN AutoIt Studio\Projects\PMU\PMU.au3 (31) : ==> COM Error intercepted !
err.number is: 0x000000A9
err.windescription: Variable is not of type 'Object'.
err.description is:
err.source is:
err.helpfile is:
err.helpcontext is:
err.lastdllerror is: 0
err.scriptline is: 31
err.retcode is: 0x00000000
Merci
Origine : version d'autoit (3.3.14.x)
Solution : downgrader en 3.3.12.x