Jump to content

_IETableGetCollection on page that needs to be navigated to


Recommended Posts

I'm trying to get table data from a webpage that needs to be navigated to. I am currently using _IECreate to create an IE object, then using some more code to login to the site. After login is confirmed, I need to navigate to another page and get table data from it. 

My code looks like this:

$oIE = _IECreate("url")

; run login script

_IENavigate($oIE,"https://.....tablepage")

$oTable = _IETableGetCollection($oIE)

ConsoleWrite("oTable = " & $oTable & @CRLF)
ConsoleWrite("oTable error = " & @ERROR)

The object $oTable appears to be empty, and an object type error is returned.

The messages written into the console are:

oTable = 
oTable error = 0--> IE.au3 V2.4-0 Error from function _IETableWriteToArray, $_IEStatus_InvalidObjectType
 
 
I'm not entirely sure that the _IENavigate function updates the $oIE object, so that might be a source of problems. 
 
The tables on the navigated page are of the normal html type, beginning with <table id=...>, so I don't think the page syntax is an issue.
 
Any help is greatly appreciated 
 
 

 

Link to comment
Share on other sites

$oTable is an object and cannot just be dumped to the console like that.

untested as I don't know the URL:

#include <Array.au3>
$oIE = _IECreate("url")

; run login script

_IENavigate($oIE, "https://.....tablepage")

$oTable = _IETableGetCollection($oIE, 0); Get first table in the collection so we return a table object and not a collection
Local $aTable = _IETableWriteToArray($oTable); Write that table to an array so we can see it
_ArrayDisplay($aTable)

EDIT: If the table you are after is not the first table in the collection, just modify the second parameter of _IETableGetCollection

Edited by danwilli
Link to comment
Share on other sites

Hey Adam!

I'm a novice at this but here's how I've done that in the past. In my script below I'm getting the 4th table.  Index the table you want to get after you find the index of it on the page and write it to an array.  You can use _arraydisplay to see where to access the info you need if you just need a certain instance in the table every time.

Hope this helps.  Sorry if not.

$invtable = _IETableGetCollection($oIE, 4)
$invarray = _IETableWriteToArray($invtable, True)
If UBound($invarray) > 1 Then
 $status = $invarray[1][5]
 $payment = $invarray[1][4]
 $checknum = $invarray[1][6]
 ;$diff = ($payment - $cost)
 _ExcelWriteCell($oExcel, $status, $row, 3)
 _ExcelWriteCell($oExcel, $payment, $row, 4)
 _ExcelWriteCell($oExcel, $checknum, $row, 5)
 _ExcelWriteCell($oExcel, "=D"&$row&"-B"&$row, $row, 6)
 ;_ExcelWriteCell($oExcel, $diff , $row, 6)
 Else
 _ExcelWriteCell($oExcel, "Not Found", $row, 4)
EndIf

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

×
×
  • Create New...