Jump to content

Recommended Posts

Posted

hi

I want to get Link with same class and put in array, the click on the link

i use this code but this just click on link 0 in array

; Get a reference to the collection of forms on a page,
; and then loop through them displaying information for each
; demonstrating use of form index

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://hiva.site")
; $oFound = ""
Global $oFound [10]
$colLinks = _IELinkGetCollection($oIE)

   For $oLink In $colLinks

      For $Count=0 to 9
         If $oLink.className & "" = "movie-poster col-xs-3 no-padding" Then
            $oFound ["Count"] = $oLink
         EndIf
      Next

   Next


 _IEAction ($oFound [1], "click")

 

Posted (edited)

Should be :

For $Count=0 to 9
   If $oLink.className & "" = "movie-poster col-xs-3 no-padding" Then
      $oFound [$Count] = $oLink
   EndIf
Next

The way you wrote it, "Count" is converted to 0.  But I do not understand why you would put 10 times the same exact object in the array.

Maybe this is what you meant to write ? 

#include <IE.au3>

Local $oIE = _IECreate("http://hiva.site")
Local $oFound [10], $Count = 0
Local $colLinks = _IELinkGetCollection($oIE)
For $oLink In $colLinks
  If $oLink.className = "movie-poster col-xs-3 no-padding" Then
    $oFound [$Count] = $oLink
    $Count += 1
    If $Count = UBound($oFound) Then ExitLoop
  EndIf
Next

_IEAction ($oFound [1], "click")

 

Edited by Nine
Posted
  On 1/10/2020 at 6:36 PM, Nine said:

Should be :

For $Count=0 to 9
   If $oLink.className & "" = "movie-poster col-xs-3 no-padding" Then
      $oFound [$Count] = $oLink
   EndIf
Next

The way you wrote it, "Count" is converted to 0.  But I do not understand why you would put 10 times the same exact object in the array.

Maybe this is what you meant to write ? 

#include <IE.au3>

Local $oIE = _IECreate("http://hiva.site")
Local $oFound [10], $Count = 0
Local $colLinks = _IELinkGetCollection($oIE)
For $oLink In $colLinks
  If $oLink.className = "movie-poster col-xs-3 no-padding" Then
    $oFound [$Count] = $oLink
    $Count += 1
    If $Count = UBound($oFound) Then ExitLoop
  EndIf
Next

_IEAction ($oFound [1], "click")

 

Expand  

Thank you , it worked.

if i need to count the element that have class( movie-poster col-xs-3 no-padding ) , what Sohuld I do?

 

Posted (edited)

It is there. $Count += 1 already doing it but it is stopping at 10 elements since the array is bound to 10, you can increase the number of elements if you wish to.  Add MsgBox (0,"",$Count) after loop to know how many links were found.

Edited by Nine
Posted
  On 1/10/2020 at 7:20 PM, Nine said:

It is there. $Count += 1 already doing it but it is stopping at 10 elements since the array is bound to 10, you can increase the number of elements if you wish to.  Add MsgBox (0,"",$Count) after loop to know how many links were found.

Expand  

thank you , when there is no link , just java script click , what i should to do for auto click?

Posted
  On 1/10/2020 at 7:20 PM, Nine said:

It is there. $Count += 1 already doing it but it is stopping at 10 elements since the array is bound to 10, you can increase the number of elements if you wish to.  Add MsgBox (0,"",$Count) after loop to know how many links were found.

Expand  

when i increase number, the loop doesn't stop until it is run as number

 
If $Count = UBound($oFound) Then ExitLoop
Posted

Here is a way which will build a dynamic list of addresses and then open each address in a new tab (wasn't sure if you wanted to print this list or open each item).

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

Const $navOpenInNewTab = 0x0800

Local $oIE = _IECreate("https://hiva.site/", 1)
Sleep(3000)
Global $aLinks[0]
Global $oLinks = _IELinkGetCollection($oIE)
If IsObj($oLinks) Then
    For $i = 0 To $oLinks.length - 1
        If $oLinks($i).className = "movie-poster col-xs-3 no-padding" Then
            ReDim $aLinks[UBound($aLinks) + 1] ;~ Expand $aLinks Array
            $aLinks[UBound($aLinks) - 1] = $oLinks($i).href
        EndIf
    Next
EndIf
_ArrayDisplay($aLinks)
For $i = 0 To UBound($aLinks) - 1
    $oIE.Navigate2($aLinks[$i], $navOpenInNewTab)
Next

 

Posted
  On 1/10/2020 at 9:36 PM, Subz said:

Here is a way which will build a dynamic list of addresses and then open each address in a new tab (wasn't sure if you wanted to print this list or open each item).

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

Const $navOpenInNewTab = 0x0800

Local $oIE = _IECreate("https://hiva.site/", 1)
Sleep(3000)
Global $aLinks[0]
Global $oLinks = _IELinkGetCollection($oIE)
If IsObj($oLinks) Then
    For $i = 0 To $oLinks.length - 1
        If $oLinks($i).className = "movie-poster col-xs-3 no-padding" Then
            ReDim $aLinks[UBound($aLinks) + 1] ;~ Expand $aLinks Array
            $aLinks[UBound($aLinks) - 1] = $oLinks($i).href
        EndIf
    Next
EndIf
_ArrayDisplay($aLinks)
For $i = 0 To UBound($aLinks) - 1
    $oIE.Navigate2($aLinks[$i], $navOpenInNewTab)
Next

 

Expand  

Thank you , when there is no link , just java script click , what i should to do for auto click?

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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