StefanoVR Posted April 28, 2014 Posted April 28, 2014 Good morning. I have a problem with a website. I need to read the ToolTips (span title) instead then the .innertext of a table (the text is truncated, instead tooltips are complete). I checked the default _IETableWriteToArray included in IE.au and changed this way but didn't work! Any suggestion? expandcollapse popup_IETableWriteToArrayStefano(ByRef $o_object, $f_transpose = False,$sModalita = Default) If $sModalita = Default or $sModalita = "InnerText" Then Local $sDaLeggere = "InnerText" Else Local $sDaLeggere = "SpanTitle" EndIf If Not IsObj($o_object) Then __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_InvalidDataType") Return SetError($_IEStatus_InvalidDataType, 1, 0) EndIf ; If Not __IEIsObjType($o_object, "table") Then __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_InvalidObjectType") Return SetError($_IEStatus_InvalidObjectType, 1, 0) EndIf ; Local $i_cols = 0, $tds, $i_col Local $trs = $o_object.rows For $tr In $trs $tds = $tr.cells $i_col = 0 For $td In $tds $i_col = $i_col + $td.colSpan Next If $i_col > $i_cols Then $i_cols = $i_col Next Local $i_rows = $trs.length Local $a_TableCells[$i_cols][$i_rows] Local $col, $row = 0 For $tr In $trs $tds = $tr.cells $col = 0 For $td In $tds If $sDaLeggere = "InnerText" Then $a_TableCells[$col][$row] = String($td.innerText) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_COMError", @error) Return SetError($_IEStatus_ComError, @error, 0) EndIf Else $a_TableCells[$col][$row] = String($td.title) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_COMError", @error) Return SetError($_IEStatus_ComError, @error, 0) EndIf EndIf $col = $col + $td.colSpan Next $row = $row + 1 Next If $f_transpose Then Local $i_d1 = UBound($a_TableCells, $UBOUND_ROWS), $i_d2 = UBound($a_TableCells, $UBOUND_COLUMNS), $aTmp[$i_d2][$i_d1] For $i = 0 To $i_d2 - 1 For $j = 0 To $i_d1 - 1 $aTmp[$i][$j] = $a_TableCells[$j][$i] Next Next $a_TableCells = $aTmp EndIf Return SetError($_IEStatus_Success, 0, $a_TableCells) EndFunc ;==>_IETableWriteToArrayStefano
StefanoVR Posted April 28, 2014 Author Posted April 28, 2014 the problem is probably at this line: $a_TableCells[$col][$row] = String($td.title) And i receive as result an empty table...
Solution StefanoVR Posted April 29, 2014 Author Solution Posted April 29, 2014 Problem solved using .outerHTML For $tr In $trs $tds = $tr.cells $col = 0 For $td In $tds If $sDaLeggere = "InnerText" Then $a_TableCells[$col][$row] = String($td.innerText) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_COMError", @error) Return SetError($_IEStatus_ComError, @error, 0) EndIf Else Local $sTemp = String($td.outerHTML) If @error Then ; Trap COM error, report and return __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IEStatus_COMError", @error) Return SetError($_IEStatus_ComError, @error, 0) EndIf ;MsgBox(0,"Debug",$sTemp) If StringInStr($sTemp,"SPAN title",0,1,1) > 0 Then Local $nCarattereInizio = StringInStr($sTemp,"SPAN title",0,1,1) + StringLen("SPAN title") + 1 Local $nCarattereFine = StringInStr($sTemp,">",0,1,$nCarattereInizio) Local $sSpanTitle = StringMid($sTemp,$nCarattereInizio,$nCarattereFine-$nCarattereInizio) $sSpanTitle = StringReplace($sSpanTitle ,'"','') ;MsgBox(0,"DBG- SPAN TITLE",$sSpanTitle) $sTemp = $sSpanTitle EndIf $a_TableCells[$col][$row] = $sTemp EndIf $col = $col + $td.colSpan Next $row = $row + 1 Next
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