Jump to content

Recommended Posts

Posted (edited)

Here is the script for the variable I want to find:

Local $oSunHrsTD = _IETagNameGetCollection($oFrameobj, "span").item(138)

The Item(138) for the span elemets is a dynamic number based on the index of all span objects on the webpage I am trying to send inputs to. 

Based on the span.item(#) the corresponding InnerText for that element is the value that I want to get. Which I use the following script:

Local $oSunHrs = $oSunHrsTD.InnerText

Global $otime = _IECreate ("https://somewebsite.banana")
_IELoadWait($otime)
Local $oFrameobj = _IEFrameGetObjByName($otime, "gsft_main")
Local $oLinks = _IETagNameGetCollection($oFrameobj, "a")
For $oLink In $oLinks
    If $oLink.ClassName  = "linked formlink" Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
 Next
 
_IEloadWait($oFrameobj)
Local $oMonHrsTD = _IETagNameGetCollection($oFrameobj, "span").item(139)
Local $oMonHrs = $oMonHrsTD.InnerText

_IELoadWait($oFrameobj)
Local $oFrameobj = _IEFrameGetObjByName($otime, "gsft_main")
Local $oMonHrs = _IETagNameGetCollection($oFrameobj, "SPAN")
    For $oMonHr In $oMonHrs
        If $oMonHr.ClassName = "aggregate_value" Then 
            If $oMonHr.innertext >= "8" Then
            Local $oMonAdjHr = (8 - $oMonHR.Innertext)
            ConsoleWrite( $oMonHrs &@CRLF )
            MsgBox (0, "Adjusted Value", $oMonAdjHr)
            ExitLoop
            EndIf
        EndIf
    Next

 

Where I get confused is how I find Item(#) if all I have is the InnerText. Since the InnerText is static and the Item# is dynamic:

$oSunHrsTD = _IETagNameGetCollection($oFrameobj, "span").item( "x").InnerText = ("sometext")

How can i get the X value??

 

Edited by TheGreatMomo
added code example
Posted

Couldn't something like this work ?

Local $index = 0
Local $oMonHrs = _IETagNameGetCollection($oFrameobj, "SPAN")
    For $oMonHr In $oMonHrs
        If $oMonHr.ClassName = "aggregate_value" Then 
            If $oMonHr.innertext >= "8" Then
            Local $oMonAdjHr = (8 - $oMonHR.Innertext)
            ConsoleWrite("index=" $index & ", " & $oMonHrs &@CRLF )
            MsgBox (0, "Adjusted Value", $oMonAdjHr)
            ExitLoop
            EndIf
        EndIf
        $index += 1
    Next

 

  • 2 weeks later...
Posted
On 10/16/2018 at 5:47 AM, Danp2 said:

@TheGreatMomo Did you ever look into the jQuerify solution as previously suggested?

Yeah, I couldn't seem to get that to work properly, I was receiving invalid element type errors and gave up on that way and found a workaround using the item number method, but recently ran into an issue because the .item(#) method is dynamic and presented inconsistent results and very susceptible to changes on the source site. 

The index method posted by Mikell looks promising since I can loop through an index until a requested value is present. I'll have to give that a shot once my current project calms down at work. Been dealing with a multi-thousand user migration and database conversion to a new system at work, its been a very busy month.

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...