Sign in to follow this  
Followers 0
litlmike

_ietablewritetoarray() From Ie.au3

5 posts in this topic

I would like to grab the table on this webpage. I am using _IETableWriteToArray(), from IE.au3. Can anyone tell me, if _IETableWriteToArray() grabs all the info on the table or just 1 column? If it can only get 1 column, is there a way to using it to obtain the data from each column? When I use it now, it only gets the info from the first column.

Thanks in advance.

http://pda.hko.gov.hk/wxreporte.htm

Share this post


Link to post
Share on other sites



I would like to grab the table on this webpage. I am using _IETableWriteToArray(), from IE.au3. Can anyone tell me, if _IETableWriteToArray() grabs all the info on the table or just 1 column? If it can only get 1 column, is there a way to using it to obtain the data from each column? When I use it now, it only gets the info from the first column.

Thanks in advance.

http://pda.hko.gov.hk/wxreporte.htm

I just modified a script I made a while back.

#include <IE.au3>
#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>

$Form1 = GUICreate("Hong Kong Observatory", 620, 440, 200, 125)
$List1 = GUICtrlCreateListView("Place|Temp", 5, 35, 610, 365)
$Button1 = GUICtrlCreateButton("GO", 5, 10, 33, 21, $BS_DEFPUSHBUTTON)
$StatusBar1 = _GuiCtrlStatusBarCreate ($Form1, 620, "", $SBT_TOOLTIPS)
_GuiCtrlStatusBarSetMinHeight ($StatusBar1, 35)
_GuiCtrlStatusBarSetText ($StatusBar1, ' Click the "GO" button.')
$Progress1 = GUICtrlCreateProgress(410, 412, 200, 20)
GUICtrlSetResizing($Progress1, $GUI_DOCKSTATEBAR)
GUICtrlSetState($Progress1, $GUI_HIDE)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            _GUICtrlListViewDeleteAllItems ($List1)
            _GuiCtrlStatusBarSetText ($StatusBar1, ' Gathering data, Please Wait....')
                GUICtrlSetData($Progress1, 0)
                GUICtrlSetState($Progress1, $GUI_SHOW)              
                Ping("www.google.com")
                If @error Then
                    MsgBox(0, "Connection Error!", "There was a problem connecting to the internet.")
                    _GuiCtrlStatusBarSetText ($StatusBar1, ' Check you internet connection and try again.')
                    ContinueLoop
                EndIf
                $oIE = _IECreate (0)
                GUICtrlSetData($Progress1, 10)
                _IENavigate ($oIE, "http://pda.hko.gov.hk/wxreporte.htm")
                GUICtrlSetData($Progress1, 20)
                                
            ; Get a reference to the second table on the webpage (where the data is stored)
                $oTable = _IETableGetObjByIndex ($oIE, 1)
                GUICtrlSetData($Progress1, 70)
                
            ; Read the table cells into a 2-D array
                $aProfile = _IETableWriteToArray ($oTable)
                GUICtrlSetData($Progress1, 80)
                
                _IEQuit ($oIE)
                GUICtrlSetData($Progress1, 90)
                
            ; Write the array contents to the listview
                For $i = 0 To UBound($aProfile, 2) - 1
                    If $aProfile[0][$i] == 0 Then ContinueLoop
                    Local $lv_item = GUICtrlCreateListViewItem($aProfile[0][$i] & "|" & $aProfile[1][$i], $List1)
                Next
                GUICtrlSetData($Progress1, 100)
                _GUICtrlListViewSetColumnWidth ($List1, 0, $LVSCW_AUTOSIZE)
                _GUICtrlListViewSetColumnWidth ($List1, 1, $LVSCW_AUTOSIZE_USEHEADER)
                _GuiCtrlStatusBarSetText ($StatusBar1, ' Reading data complete.')
                GUICtrlSetState($Progress1, $GUI_HIDE)
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

I just modified a script I made a while back.

#include <IE.au3>
#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>

$Form1 = GUICreate("Hong Kong Observatory", 620, 440, 200, 125)
$List1 = GUICtrlCreateListView("Place|Temp", 5, 35, 610, 365)
$Button1 = GUICtrlCreateButton("GO", 5, 10, 33, 21, $BS_DEFPUSHBUTTON)
$StatusBar1 = _GuiCtrlStatusBarCreate ($Form1, 620, "", $SBT_TOOLTIPS)
_GuiCtrlStatusBarSetMinHeight ($StatusBar1, 35)
_GuiCtrlStatusBarSetText ($StatusBar1, ' Click the "GO" button.')
$Progress1 = GUICtrlCreateProgress(410, 412, 200, 20)
GUICtrlSetResizing($Progress1, $GUI_DOCKSTATEBAR)
GUICtrlSetState($Progress1, $GUI_HIDE)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            _GUICtrlListViewDeleteAllItems ($List1)
            _GuiCtrlStatusBarSetText ($StatusBar1, ' Gathering data, Please Wait....')
                GUICtrlSetData($Progress1, 0)
                GUICtrlSetState($Progress1, $GUI_SHOW)              
                Ping("www.google.com")
                If @error Then
                    MsgBox(0, "Connection Error!", "There was a problem connecting to the internet.")
                    _GuiCtrlStatusBarSetText ($StatusBar1, ' Check you internet connection and try again.')
                    ContinueLoop
                EndIf
                $oIE = _IECreate (0)
                GUICtrlSetData($Progress1, 10)
                _IENavigate ($oIE, "http://pda.hko.gov.hk/wxreporte.htm")
                GUICtrlSetData($Progress1, 20)
                                
        ; Get a reference to the second table on the webpage (where the data is stored)
                $oTable = _IETableGetObjByIndex ($oIE, 1)
                GUICtrlSetData($Progress1, 70)
                
        ; Read the table cells into a 2-D array
                $aProfile = _IETableWriteToArray ($oTable)
                GUICtrlSetData($Progress1, 80)
                
                _IEQuit ($oIE)
                GUICtrlSetData($Progress1, 90)
                
        ; Write the array contents to the listview
                For $i = 0 To UBound($aProfile, 2) - 1
                    If $aProfile[0][$i] == 0 Then ContinueLoop
                    Local $lv_item = GUICtrlCreateListViewItem($aProfile[0][$i] & "|" & $aProfile[1][$i], $List1)
                Next
                GUICtrlSetData($Progress1, 100)
                _GUICtrlListViewSetColumnWidth ($List1, 0, $LVSCW_AUTOSIZE)
                _GUICtrlListViewSetColumnWidth ($List1, 1, $LVSCW_AUTOSIZE_USEHEADER)
                _GuiCtrlStatusBarSetText ($StatusBar1, ' Reading data complete.')
                GUICtrlSetState($Progress1, $GUI_HIDE)
    EndSelect
WEnd
Exit

AHHHH.... I see now. Cool script btw. I think I know what to do now....brb....

Yes I do! Thanks man!

Share this post


Link to post
Share on other sites

AHHHH.... I see now. Cool script btw. I think I know what to do now....brb....

Yes I do! Thanks man!

No problem, glad I could help.

Share this post


Link to post
Share on other sites

For the record, _IETableWriteToArray() loads all rows and columns of a table into a 2-D array.

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

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