Ozzy Posted December 29, 2007 Share Posted December 29, 2007 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? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 29, 2007 Share Posted December 29, 2007 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? 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 Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 29, 2007 Moderators Share Posted December 29, 2007 (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 December 29, 2007 by big_daddy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now