Jump to content

Recommended Posts

Posted

hello

i have a script and i want to have the new html when i validate . How to refresh $oIE for continue request

 

Local $oIE = _IECreate("http://speedosurf.com/compte/login")

sleep(1000)

$Input_Name  = _IEGetObjByName($oIE, "pseudo")
_IEFormElementSetValue($Input_Name, "test")
$Input_Name  = _IEGetObjByName($oIE, "pass")
_IEFormElementSetValue($Input_Name, "test")

sleep(1000)

$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement in $oElements
    If $oElement.type = "submit" Then
        _IEAction($oElement, "click")
        Exitloop
    EndIf
 Next

 

Posted
really sorry for my english, but i wish i could have access to the source code of the validated page
Posted (edited)

sorry, in fact after i click, i want to load the new source of $oIE

Edited by Moi
Posted

Maybe this is what you want :

#include <Constants.au3>
#include <IE.au3>

Local $oIE = _IECreate("http://speedosurf.com/compte/login")

$Input_Name  = _IEGetObjByName($oIE, "pseudo")
_IEFormElementSetValue($Input_Name, "test")
$Input_Name  = _IEGetObjByName($oIE, "pass")
_IEFormElementSetValue($Input_Name, "test")

sleep(1000)

$bFound = False
$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement in $oElements
    If $oElement.type = "submit" Then
        $bFound = True
        _IEAction($oElement, "click")
        Exitloop
    EndIf
Next

If Not $bFound Then Exit MsgBox ($MB_SYSTEMMODAL,"Erreur","Unable to find submit button")
_IELoadWait ($oIE)

$sHTML = _IEBodyReadHTML ($oIE)
ConsoleWrite ($sHTML & @CRLF)

 

Posted

Oh, I see what you mean.  You don't have to do anything.  $oIE is "refreshed" automatically since it is an object aiming a specific IE instance. Just make sure, after the click, you wait till the page is fully loaded as I have shown you before.

Posted
#include <Constants.au3>
#include <IE.au3>

Local $oIE1 = _IECreate("http://speedosurf.com/compte/login")

if _IEGetObjByName($oIE1, "pseudo")<>"" Then

   $Input_Name  = _IEGetObjByName($oIE1, "pseudo")
   _IEFormElementSetValue($Input_Name, "test")
   $Input_Name  = _IEGetObjByName($oIE1, "pass")
   _IEFormElementSetValue($Input_Name, "test")
   sleep(1000)
   $oElements = _IETagNameGetCollection($oIE1, "button")
   For $oElement in $oElements
      If $oElement.type = "submit" Then
         _IEAction($oElement, "click")
      EndIf
   Next
   sleep(1000)

   Local $oIE = _IECreate("http://speedosurf.com/surf")

Else
   Local $oIE = _IECreate("http://speedosurf.com/surf")

EndIf

_IEQuit($oIE1)

$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement in $oElements
   ConsoleWrite ( $oElement.innertext &@crlf)
   if StringInStr($oElement.innertext,"marrer le Surf",True) Then
      _IEAction($oElement, "click")
   EndIf
Next

this is the complete code but for working i run another _IECreate

Posted

Here should work better this way :

#include <Constants.au3>
#include <IE.au3>

Local $oIE = _IECreate("http://speedosurf.com/compte/login")

$Input_Name = _IEGetObjByName($oIE, "pseudo")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Unable to find pseduo")
_IEFormElementSetValue($Input_Name, "test")
$Input_Name = _IEGetObjByName($oIE, "pass")
_IEFormElementSetValue($Input_Name, "test")

Sleep(1000)

$bFound = False
$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement In $oElements
  If $oElement.type = "submit" Then
    $bFound = True
    _IEAction($oElement, "click")
    ExitLoop
  EndIf
Next
If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur", "Unable to find submit button")
_IELoadWait($oIE)

$bFound = False
$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement In $oElements
  ConsoleWrite($oElement.innertext & @CRLF)
  If StringInStr($oElement.innertext, "marrer le Surf", True) Then
    $bFound = True
    _IEAction($oElement, "click")
    ExitLoop
  EndIf
Next

If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur", "Unable to find Démarrer le Surf")
_IELoadWait($oIE)

; continue ton script

_IEQuit($oIE)

Untested

Posted

Ok, I found the problem.  The site creates a new object for each page.  So the old $oIE refers to the previous page.  You need to attach to the new page like this :

#include <Constants.au3>
#include <IE.au3>
#include <Array.au3>

Local $oIE = _IECreate("http://speedosurf.com/compte/login")

$Input_Name = _IEGetObjByName($oIE, "pseudo")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Unable to find pseduo")
_IEFormElementSetValue($Input_Name, "LoginName")
$Input_Name = _IEGetObjByName($oIE, "pass")
_IEFormElementSetValue($Input_Name, "MyPassword")

Sleep(1000)

$bFound = False
$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement In $oElements
  If $oElement.type = "submit" Then
    $bFound = True
    _IEAction($oElement, "click")
    ExitLoop
  EndIf
Next
If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur", "Unable to find submit button")
_IELoadWait($oIE)

Sleep (3000)

$oIE = _IEAttach ("Compte", "title")
$bFound = False
Local $sMyString = "Surfer"
   Local $oLinks = _IETagNameGetCollection($oIE, "a")
   For $oLink In $oLinks
      Local $sLinkText = _IEPropertyGet($oLink, "innerText")
      ConsoleWrite ($sLinkText & @CRLF)
      If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        $bFound = True
        ExitLoop
      EndIf
   Next

If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur", "Unable to find Surfer link")
_IELoadWait($oIE)

Sleep (3000)
$oIE = _IEAttach ("Surfer", "title")
$bFound = False
$oElements = _IETagNameGetCollection($oIE, "button")
For $oElement In $oElements
  ConsoleWrite($oElement.innertext & @CRLF)
  If StringInStr($oElement.innertext, "marrer le Surf", True) Then
    $bFound = True
    _IEAction($oElement, "click")
    ExitLoop
  EndIf
Next

If Not $bFound Then Exit MsgBox($MB_SYSTEMMODAL, "Erreur", "Unable to find Démarrer le Surf")
_IELoadWait($oIE)

; continue ton script

;_IEQuit($oIE)

 

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
×
×
  • Create New...