Sign in to follow this  
Followers 0
allSystemsGo

Display the last array only

4 posts in this topic

I want to only display the last table that is found on the webpage...

Suggestions on doing this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <guilistview.au3>
#include <StaticConstants.au3>
#include <IE.au3>

$fIni="c:\temp\zip.ini"
$count= 1

$zip=IniRead($fIni,"Zip",$count,"NotFound")
$url="http://hosted.where2getit.com/truevalue/tv2.html?form=locator_search&addressline="&$zip&"&search=&geoip=1"
$oIE=_IECreate($url,0,0,'','')
_IENavigate($oIE,$url)
_IEPropertySet($oIE,"silent","true")
_IETableReport($oIE)
;$sHtml = _IEDocReadHTML($oIE)
;$filename="tv"&$count&".html"
;$file = FileOpen($filename, 2)
;FileWrite($file, $sHTML)
;FileClose($file)


Func _IETableReport($oIE)
Local $iIndex = 0

$colTables = _IETableGetCollection($oIE)
MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")

for $oTable In $colTables
;===== stolen from IE include _IETableWriteToArray, to find errors
Local $i_cols = 0, $tds, $i_col
Local $trs = $oTable.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
If $i_cols = 0 Or $i_cols = 0 Then
MsgBox(1, "Failure to make good array from table", "Column count=" & $i_cols & "  Row count =" & $i_cols )
;======== end of , find array problems
Else
$aTableData = _IETableWriteToArray($oTable)
_ArrayDisplay($aTableData, "Table #" & $iIndex)
$iIndex += 1

EndIf
next
EndFunc

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you can call the ietablegetcol twice (might need to do $colTables.length - 1...forget if it's zero based

$colTables = _IETableGetCollection($oIE)
MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")

$oTable = _IETableGetCollection($oIE,$colTables.length-1)

along the same lines, you can select the item:

$colTables = _IETableGetCollection($oIE)
MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")

$oTable = $colTables.item($colTables.length-1)

edit: it's zero based...added in the -1

if you want to keep your loop going though, then you can add in a counter...but there is probably a method to get the current item of the collection...

$oCounter = 0
ConsoleWrite($oLinkCol.length & @CRLF)
For $oLink in $oLinkCol
 ConsoleWrite($oLink.href & @CRLF)
 $oCounter+=1
 If $oCounter = $oLinkCol.length then MsgBox(1,1,1)
Next
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

This does not seem to be giving me the results I am expecting. In the end, I really do not care if it is displayed, I just want the contents of the last array copied and put into a text file.

Share this post


Link to post
Share on other sites

This gets me the last array only, but does not copy the array,,,suggestions?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <guilistview.au3>
#include <StaticConstants.au3>
#include <IE.au3>

$fIni="c:\temp\zip.ini"
$count= 1

$zip=IniRead($fIni,"Zip",$count,"NotFound")
$url="http://hosted.where2getit.com/truevalue/tv2.html?form=locator_search&addressline="&$zip&"&search=&geoip=1"
$oIE=_IECreate($url)
_IENavigate($oIE,$url)
_IEPropertySet($oIE,"silent","true")
_IETableReport($oIE)
;$sHtml = _IEDocReadHTML($oIE)
;$filename="tv"&$count&".html"
;$file = FileOpen($filename, 2)
;FileWrite($file, $sHTML)
;FileClose($file)


Func _IETableReport($oIE)
Local $iIndex = 0

;$colTables = _IETableGetCollection($oIE)
;MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")
$colTables = _IETableGetCollection($oIE)
MsgBox(0, "Table Info", "There are " & @extended & " tables on the page")

$oTable = _IETableGetCollection($oIE,$colTables.length-1)

for $oTable In $colTables
;===== stolen from IE include _IETableWriteToArray, to find errors
Local $i_cols = 0, $tds, $i_col
Local $trs = $oTable.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
If $i_cols = 0 Or $i_cols = 0 Then
MsgBox(1, "Failure to make good array from table", "Column count=" & $i_cols & "  Row count =" & $i_cols )
;======== end of , find array problems
Else
$aTableData = _IETableWriteToArray($oTable)
If $iIndex= 8 Then
;_ArrayDisplay($aTableData, "Table #" & $iIndex)
_ArrayToClip($aTableData)
MsgBox(0, "_ArrayToClip() Test", ClipGet())
Else
Sleep(10)
EndIf
$iIndex += 1
;$copyArray=_ArrayToClip($aTableData,8)
;ClipPut($copyArray)


EndIf
next
EndFunc

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