Jump to content

Get IE Link and put in array


 Share

Recommended Posts

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")

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

35 minutes ago, 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")

 

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?

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

1 hour ago, 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.

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

Link to comment
Share on other sites

1 hour ago, 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.

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


 
If $Count = UBound($oFound) Then ExitLoop
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

10 hours ago, 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

 

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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