Jump to content

Help With Internet Explorer Automation Udf Library


Recommended Posts

Hello,

I need to make a script to extract from this site :

Weather

Some infos (temp,humd,..) every day at 8 o'clock.

I ´m using UDF library for Internet explorer. I think, i can use it to perform this action.

But it´s very dificult to find the ID´s or name of the html elements who hold the information.

i use this :

_IETableGetObjByIndex($oIE, 4)

But this code extract to me a long string with all the sub-strings inside the weather table. Maybe i can make a parser to have the information but i want to know if he exist an order way.

Thanks for your help.

Edited by danisam
Link to comment
Share on other sites

Thanks for your response.

How can you know, than the informations are stok into the table number 2 ?

i need to know where to find my information.

$oTable2 = _IETableGetObjByIndex($oIE, 4)

$aWeather = _IETableWriteToArray($oTable2)

MsgBox(4096, "Test",$aWeather[0][0] ,100)

Whith this code i view all the content of the weather table at the cell [0][0] of the 2D array.

there is an other array into this cell ?

thanks

Edited by danisam
Link to comment
Share on other sites

  • Moderators

First off with the code you provided you are actually reading the fifth table.

Example:

; This reads the first table
$oTable = _IETableGetObjByIndex($oIE, 0)
; This reads the second table
$oTable = _IETableGetObjByIndex($oIE, 1)

I haven't had much time, but this is what I've come up with so far.

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

$Form1 = GUICreate("Prónostico horario", 620, 440, 200, 125)
$List1 = GUICtrlCreateListView("Characteristics|Numbers", 8, 50, 600, 350)
$Button1 = GUICtrlCreateButton("GO", 240, 20, 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 ()
                GUICtrlSetData($Progress1, 10)
                _IENavigate ($oIE, "http://espanol.weather.com/weather/hourbyhour/MXCL0013")
                GUICtrlSetData($Progress1, 20)
                                
            ; Get a reference to the eighth table on the webpage (where the data is stored)
                $oTable = _IETableGetObjByIndex ($oIE, 7)
                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
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...