Bonjour,
Bon finalement avec beaucoup de recherche et d'analyse de différent post un grand merci a : mikell
Que ce soit sur le forum anglais ou français. J'ai résolu mon problème en utilisant de petites astuces.
Je posts mon code si ça peut aider.
Mon site étant spécifique, j'ai enlevé les détails "métier"
Code : Tout sélectionner
#include <Excel.au3> ; on inclus les variable excel dans notre code pour pouvoir s'en servir.
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
;#RequireAdmin
#include <IE.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; on appel le site sous IE ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Local $oIE = _IECreate("mon site",1)
Sleep(500)
_IELinkClickByText ($oIE,"Consultation",0,1) ;;;; on click sur le lien consultation
Sleep(2000)
Local $oDiv = _IEGetObjById($oIE, "searchboxid") ;;;; on cherche lla barre de recherche
_IEFormElementSetValue($oDiv, "texte") ;;; on y implémente le texte a rechercher
sleep (2000)
$oLinks = _IETagNameGetCollection($oIE, "button") ;;;; on click sur le bouton Recherche
For $oLink In $oLinks
If String($oLink.type) = "button" And String($oLink.value) = "Recherche" Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next
sleep (2000)
Dim $html = _IEBodyReadText ($oIE) ;;; on lit le code html au format text
$string1 = "Accès"
$Array1 = StringRegExp($html,"(?im)(^.*\b" & $string1 & "\b.*)(?:\r\n?$)",3) ; on y extrait Accès "texte..." que le colle dans un Array (tableau virtuel
$numb = UBound ($Array1)
;;;; ubound : on compte le nombre de référence dans le tableau
$string11 = "La recherche n'a renvoyé aucun résultat." ; on va chercher s'il a une erreur
$Array11 = StringRegExp($html, $string11 ,3)
$numb1 = UBound ($Array11)
;MsgBox(16, "erreur pas d'occurence", $numb)
;_ArrayDisplay($Array11)
if $numb <> 0 then
_IELinkClickByText ($oIE, $Array1[0], 0 ,1)
ElseIf $numb1 =1 Then
MsgBox(16, "erreur", "erreur")
exit
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Constitution ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
sleep (2000)
Dim $html1 = _IEBodyReadText ($oIE)
$string2 = "tesxte" ; on recherche le mot texte dans le code
$Array2 = StringRegExp($html1, $string2 & "\W.*" ,3)
$Array3 = StringSplit ($Array2[0], ")",2)
$Array4 = $Array3[0] & ")"
;_ArrayDisplay($Array4)
;MsgBox(0, "Link Info", $Array4)
$constit0 = "texte (0)"
$constit1 = "texte (1)"
$constit2 = "texte(2)"
if $Array4 = $constit0 Then
MsgBox(16, "pas de ctexte", $Array4)
ElseIf $Array4 = $constit1 Then
MsgBox(0, "1 texte", $Array4)
ElseIf $Array4 = $constit2 Then
MsgBox(0, "2 texte", $Array4)
EndIf
;;;;;;;; on quitte la recherche pas un click sur un bouton Javascript via son classname
Local $oBtns = _IETagNameGetCollection($oIE, "button")
For $oBtn In $oBtns
If String($oBtn.classname) = "mon bouton" Then
_IEAction($oBtn, "click")
EndIf
Next