Jump to content

Alternet means to collect data from IE rather than _IETableGetCollection?


Recommended Posts

I am trying to parse a web phone directory to obtain a table thats within a few tables... (DebugBar has it listed as 4 tables deep)

when i use _IETableGetCollection it seems to always get stuck on another incredibly long table created with the java in the headers of the page.. Trying to bypass the first set of tables via _IEGetObjByID (and the ID name for the second set of tables) or by trying to use the index _IETableGetCollection ($oIE, 1) never returns anything but the data from the header

basicly i'm at a loss at how to create an array from the table in the center of the page <_<

(example source html attached)

#include <IE.au3>
#AutoIt3Wrapper_run_debug_mode=Y

$oIE = _IECreate ("http://webphone.asdf.com/cgi-bin/webphones.pl?id=jd1234", 0, 1, 1)

$oDiv = _IEGetObjByID ($oIE, "tbl")

$oTable = _IETableGetCollection ($oDiv, 0)


#include <Array.au3>

Global $ArrayCont=""

; $oTable = _IETableGetCollection ($oIE, 0)
$aTableData = _IETableWriteToArray ($oTable, True)

$rows = UBound($aTableData)
$cols = UBound($aTableData,2)
$dims = UBound($aTableData, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
    $rows & " rows, " & $cols & " columns")

For $m=0 to $rows-1
    For $n=0 to $cols-1
            $ArrayCont=$ArrayCont&" | "&$aTableData[$m][$n]
    Next
    $ArrayCont=$ArrayCont&@CRLF 
Next
ClipPut($ArrayCont)
MsgBox(0,"",ClipGet())

_IEQuit ($oIE)

webphone.html

Edited by zhenyalix

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

in the meantime just painfully pulling it manually...

$sText = _IEBodyReadHTML ($oIE)
    $TextArray = StringSplit($sText, "<TBODY>", 1);15th element is the main body
    Msgbox(0,"For..IN Arraytest", $TextArray[15])

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

Actually, it is a lot more than 4 levels deep... it is 14:

#include <IE.au3>
#include <array.au3>

$oIE = _IEAttach("WEBPHONE")

$oTable = _IETableGetCollection($oIE, 13)
$aTable = _IETableWriteToArray($oTable, True)
_ArrayDisplay($aTable)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

that did it... now is there a way to see that (its 14 deep) in the DebugBar? (I ended up making a loop and counting msg boxes <_<) in the DOM section targeting the table box i can see three huge trees but failed to see how to pull those details

$sText = _IEBodyReadHTML ($oIE)
    $TextArray = StringSplit($sText, "<TBODY>", 1);15th element is the main body.. found by looping $TextArray
    $PhoneTable = $TextArray[15]
    $PhoneTable = StringReplace($PhoneTable, "<TD class=nm>", "")
    $PhoneTable = StringReplace($PhoneTable, "<TD class=vl>", "")
    $PhoneTable = StringReplace($PhoneTable, "</TD>", "")
    $PhoneTable = StringReplace($PhoneTable, "</TR>", "")
    $PhoneTable = StringReplace($PhoneTable, "<TD class=vl colSpan=4>", "")
    Msgbox(0,"For..IN Arraytest", $PhoneTable)

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

I used DebugBar... I clicked on the DebugBar "View Source" button, clicked on the "IE Interpreted Source" tab and then searched for "<table". The 14th occurance was the table that you were looking for.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

rotflmao now i really feel stupid... i have been using DebugBar for 2 days and just noticed that on the default install half of the buttons (everything past Color Picker) was covered up by another toolbar on the same line...

I'm in need of a Red Bull... or two.

Thanks Again!

Don't let that status fool you, I am no advanced memeber!

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

  • Recently Browsing   0 members

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