Sign in to follow this  
Followers 0
Ozzy

IE Table navigator

3 posts in this topic

Hi all,

I need to read table content of an HTML page...

There are many table in page (tablefull website :) )

Table I'm intressed in had 2 columns for example (key,value), now I have to find the value of a given key...

I can get "key TD" with StringInStr() & innerText proprety but how can I get next TD having that?

$oElements = _IETagNameGetCollection ($oIE, "td")

For $oElement In $oElements
    If StringInStr($oElement.innerText,"key") Then
    ;Here I found keyTD and I need to get next TD
    EndIf
Next

I tried to read $oElements like an array ( $oElements[<index>] ) but it returns parse error...

What can I do?

Share this post


Link to post
Share on other sites



Hi all,

I need to read table content of an HTML page...

There are many table in page (tablefull website :P )

Table I'm intressed in had 2 columns for example (key,value), now I have to find the value of a given key...

I can get "key TD" with StringInStr() & innerText proprety but how can I get next TD having that?

$oElements = _IETagNameGetCollection ($oIE, "td")

For $oElement In $oElements
    If StringInStr($oElement.innerText,"key") Then
;Here I found keyTD and I need to get next TD
    EndIf
Next

I tried to read $oElements like an array ( $oElements[<index>] ) but it returns parse error...

What can I do?

Just use a flag to track when the first instance is found, then continue to look for the second:

$oElements = _IETagNameGetCollection ($oIE, "td")

$fFound = False
$iIndex = 0
For $oElement In $oElements
    If StringInStr($oElement.innerText,"key") Then
        If $fFound Then 
            MsgBox(64, "Found", "Found second instance at index = " & $iIndex)
        Else
            $fFound = True
        EndIf
    EndIf
    $iIndex += 1
Next

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The easiest way to accomplish this would be _IETableWriteToArray().

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

$sURL = "SomeWebsite.com"
$oIE = _IECreate($sURL)
; Adjust the second parameter for the zero based index of your table
$oTable = _IETableGetCollection($oIE, 1)
$aTableData = _IETableWriteToArray($oTable, True)
_ArrayDisplay($aTableData)

$sValue = ""
For $i = 0 To UBound($aTableData) - 1
    If StringInStr($aTableData[$i][0], "key") Then
        $sValue = $aTableData[$i][1]
        ExitLoop
    EndIf
Next

MsgBox(0, "", "Your value is " & $sValue)
Edited by big_daddy

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0