Jump to content

Grab info from webpage page with parsing


Altainta
 Share

Recommended Posts

ok, heres a little bit more of what you asked about. Someone else could add most if this to an array and reduce the cod to about a tenth I think and still get the same results. I can't check the spacing for the date -its down on the website so its not pulling.

It has 5 stocks that update every 15 sec or when you request. . . . The IE sould not appear in the background but hidden has never worked on this pc so Im not sure if the ie is hidden for you . . .

one last thing I was thinking was maybe add a notpad of all stocks traded, then add a 'Random' button that pulls a random stock and checks up on it. Could get you looking where you haven't before . . . maybe find something of interest . . .

of course there is no error proofing so you will have to work that one out. :P

code below -longer, I know . . . but it has id tags (I am sure there are many things I coded that could have been done easier! ;) just not by me yet . . .)

CODE
;Include Autoit Functions

#include <IE.au3>

#include <Array.au3>

#include <GuiConstants.au3>

;Set Hot Keys - (They call Functions listed near the bottom)

HotKeySet("{ESC}", "Terminate")

;Create the basic GUI

$Form1 = GUICreate("My Stock Ticker", 610, 600, 300, 250)

;Stock 1

$Group11 = GUICtrlCreateGroup("Target Stock:", 24, 40, 561, 100)

$Input11 =GUICtrlCreateInput ("IFCI", 370, 120, 120, 17)

$Button11 = GUICtrlCreateButton("Update", 495, 120, 60, 17)

$Label11 = GUICtrlCreateLabel("Lt Price:", 45, 64, 85, 17)

$Label12 = GUICtrlCreateLabel("Open:", 150, 64, 85, 17)

$Label13 = GUICtrlCreateLabel("High:", 265, 64, 85, 17)

$Label14 = GUICtrlCreateLabel("Previous Close:", 380, 64, 85, 17)

$Label15 = GUICtrlCreateLabel("Date/Time:", 495, 64, 85, 17)

$Edit11 = GUICtrlCreateLabel("", 45, 88, 85, 17)

$Edit12 = GUICtrlCreateLabel("", 150, 88, 85, 17)

$Edit13 = GUICtrlCreateLabel("", 265, 88, 85, 17)

$Edit14 = GUICtrlCreateLabel("", 380, 88, 85, 17)

$Edit15 = GUICtrlCreateLabel("", 495, 88, 85, 32)

;Stock 2

$Group21 = GUICtrlCreateGroup("Target Stock:", 24, 140, 561, 100)

$Input21 =GUICtrlCreateInput ("RPL", 370, 220, 120, 17)

$Button21 = GUICtrlCreateButton("Update", 495, 220, 60, 17)

$Label21 = GUICtrlCreateLabel("Lt Price:", 45, 164, 85, 17)

$Label22 = GUICtrlCreateLabel("Open:", 150, 164, 85, 17)

$Label23 = GUICtrlCreateLabel("High:", 265, 164, 85, 17)

$Label24 = GUICtrlCreateLabel("Previous Close:", 380, 164, 85, 17)

$Label25 = GUICtrlCreateLabel("Date/Time:", 495, 164, 85, 17)

$Edit21 = GUICtrlCreateLabel("", 45, 188, 85, 17)

$Edit22 = GUICtrlCreateLabel("", 150, 188, 85, 17)

$Edit23 = GUICtrlCreateLabel("", 265, 188, 85, 17)

$Edit24 = GUICtrlCreateLabel("", 380, 188, 85, 17)

$Edit25 = GUICtrlCreateLabel("", 495, 188, 85, 32)

;Stock 3

$Group31 = GUICtrlCreateGroup("Target Stock:", 24, 240, 561, 100)

$Input31 =GUICtrlCreateInput ("REL", 370, 320, 120, 17)

$Button31 = GUICtrlCreateButton("Update", 495, 320, 60, 17)

$Label31 = GUICtrlCreateLabel("Lt Price:", 45, 264, 85, 17)

$Label32 = GUICtrlCreateLabel("Open:", 150, 264, 85, 17)

$Label33 = GUICtrlCreateLabel("High:", 265, 264, 85, 17)

$Label34 = GUICtrlCreateLabel("Previous Close:", 380, 264, 85, 17)

$Label35 = GUICtrlCreateLabel("Date/Time:", 495, 264, 85, 17)

$Edit31 = GUICtrlCreateLabel("", 45, 288, 85, 17)

$Edit32 = GUICtrlCreateLabel("", 150, 288, 85, 17)

$Edit33 = GUICtrlCreateLabel("", 265, 288, 85, 17)

$Edit34 = GUICtrlCreateLabel("", 380, 288, 85, 17)

$Edit35 = GUICtrlCreateLabel("", 495, 288, 85, 32)

;Stock 4

$Group41 = GUICtrlCreateGroup("Target Stock:", 24, 340, 561, 100)

$Input41 =GUICtrlCreateInput ("ifci", 370, 420, 120, 17)

$Button41 = GUICtrlCreateButton("Update", 495, 420, 60, 17)

$Label41 = GUICtrlCreateLabel("Lt Price:", 45, 364, 85, 17)

$Label42 = GUICtrlCreateLabel("Open:", 150, 364, 85, 17)

$Label43 = GUICtrlCreateLabel("High:", 265, 364, 85, 17)

$Label44 = GUICtrlCreateLabel("Previous Close:", 380, 364, 85, 17)

$Label45 = GUICtrlCreateLabel("Date/Time:", 495, 364, 85, 17)

$Edit41 = GUICtrlCreateLabel("", 45, 388, 85, 17)

$Edit42 = GUICtrlCreateLabel("", 150, 388, 85, 17)

$Edit43 = GUICtrlCreateLabel("", 265, 388, 85, 17)

$Edit44 = GUICtrlCreateLabel("", 380, 388, 85, 17)

$Edit45 = GUICtrlCreateLabel("", 495, 388, 85, 32)

;Stock 5

$Group51 = GUICtrlCreateGroup("Target Stock:", 24, 440, 561, 100)

$Input51 =GUICtrlCreateInput ("ifci", 370, 520, 120, 17)

$Button51 = GUICtrlCreateButton("Update", 495, 520, 60, 17)

$Label51 = GUICtrlCreateLabel("Lt Price:", 45, 464, 85, 17)

$Label52 = GUICtrlCreateLabel("Open:", 150, 464, 85, 17)

$Label53 = GUICtrlCreateLabel("High:", 265, 464, 85, 17)

$Label54 = GUICtrlCreateLabel("Previous Close:", 380, 464, 85, 17)

$Label55 = GUICtrlCreateLabel("Date/Time:", 495, 464, 85, 17)

$Edit51 = GUICtrlCreateLabel("", 45, 488, 85, 17)

$Edit52 = GUICtrlCreateLabel("", 150, 488, 85, 17)

$Edit53 = GUICtrlCreateLabel("", 265, 488, 85, 17)

$Edit54 = GUICtrlCreateLabel("", 380, 488, 85, 17)

$Edit55 = GUICtrlCreateLabel("", 495, 488, 85, 32)

;Show the finished resluts of the GUI

GUISetState(@SW_SHOW)

;Time the stock updates

$begin = TimerInit()

$wait = 15000

;Keep the GUI open and monitoring.

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE

Exit

Case (TimerDiff($begin) >= $wait)

UpdateStock()

Case ($nMsg = $Button11)

UpdateStock1()

Case ($nMsg = $Button21)

UpdateStock2()

Case ($nMsg = $Button31)

UpdateStock3()

Case ($nMsg = $Button41)

UpdateStock4()

Case ($nMsg = $Button51)

UpdateStock5()

EndSelect

WEnd

;***************************************************************************

;Update all stocks

Func UpdateStock()

UpdateStock1()

UpdateStock2()

UpdateStock3()

UpdateStock4()

UpdateStock5()

EndFunc ;==>UpdateStock

;***************************************************************************

;Update the stock 1 info

Func UpdateStock1()

;Stock 1

GUICtrlSetData($Edit11, "Loading . . .")

GUICtrlSetData($Edit12, "Loading . . .")

GUICtrlSetData($Edit13, "Loading . . .")

GUICtrlSetData($Edit14, "Loading . . .")

GUICtrlSetData($Edit15, "Loading . . .")

$Stock = GUICtrlRead($Input11)

$URL = "https://strade.sharekhan.com/rmmweb/feed/quotes.jsp?scrip=" & $Stock

$ObjIE = ObjCreate("InternetExplorer.Application")

With $ObjIE

.Visible = False

.Navigate ($URL)

Do

Sleep(50)

Until .ReadyState = 4

EndWith

$oIE = _IEAttach($Stock)

$oTable = _IETagNameGetCollection($oIE, "table", 8)

$aTable = _IETableWriteToArray($oTable, True)

;_ArrayDisplay($aTable, "Table index: ")

GUICtrlSetData($Edit11, $aTable[0][1])

GUICtrlSetData($Edit12, $aTable[5][1])

GUICtrlSetData($Edit13, $aTable[8][1])

GUICtrlSetData($Edit14, $aTable[13][1])

GUICtrlSetData($Edit15, $aTable[24][1])

$oIE.quit ()

$begin = TimerInit()

EndFunc ;==>UpdateStock1

;***************************************************************************

;Update the stock 2 info

Func UpdateStock2()

GUICtrlSetData($Edit21, "Loading . . .")

GUICtrlSetData($Edit22, "Loading . . .")

GUICtrlSetData($Edit23, "Loading . . .")

GUICtrlSetData($Edit24, "Loading . . .")

GUICtrlSetData($Edit25, "Loading . . .")

$Stock = GUICtrlRead($Input21)

$URL = "https://strade.sharekhan.com/rmmweb/feed/quotes.jsp?scrip=" & $Stock

$ObjIE = ObjCreate("InternetExplorer.Application")

With $ObjIE

.Visible = False

.Navigate ($URL)

Do

Sleep(50)

Until .ReadyState = 4

EndWith

$oIE = _IEAttach($Stock)

$oTable = _IETagNameGetCollection($oIE, "table", 8)

$bTable = _IETableWriteToArray($oTable, True)

;_ArrayDisplay($aTable, "Table index: ")

GUICtrlSetData($Edit21, $bTable[0][1])

GUICtrlSetData($Edit22, $bTable[5][1])

GUICtrlSetData($Edit23, $bTable[8][1])

GUICtrlSetData($Edit24, $bTable[13][1])

GUICtrlSetData($Edit25, $bTable[24][1])

$oIE.quit ()

$begin = TimerInit()

EndFunc ;==>UpdateStock2

;***************************************************************************

;Update the stock 3 info

Func UpdateStock3()

GUICtrlSetData($Edit31, "Loading . . .")

GUICtrlSetData($Edit32, "Loading . . .")

GUICtrlSetData($Edit33, "Loading . . .")

GUICtrlSetData($Edit34, "Loading . . .")

GUICtrlSetData($Edit35, "Loading . . .")

$Stock = GUICtrlRead($Input31)

$URL = "https://strade.sharekhan.com/rmmweb/feed/quotes.jsp?scrip=" & $Stock

$ObjIE = ObjCreate("InternetExplorer.Application")

With $ObjIE

.Visible = False

.Navigate ($URL)

Do

Sleep(50)

Until .ReadyState = 4

EndWith

$oIE = _IEAttach($Stock)

$oTable = _IETagNameGetCollection($oIE, "table", 8)

$cTable = _IETableWriteToArray($oTable, True)

;_ArrayDisplay($aTable, "Table index: ")

GUICtrlSetData($Edit31, $cTable[0][1])

GUICtrlSetData($Edit32, $cTable[5][1])

GUICtrlSetData($Edit33, $cTable[8][1])

GUICtrlSetData($Edit34, $cTable[13][1])

GUICtrlSetData($Edit35, $cTable[24][1])

$oIE.quit ()

$begin = TimerInit()

EndFunc ;==>UpdateStock3

;***************************************************************************

;Update the stock 4 info

Func UpdateStock4()

GUICtrlSetData($Edit41, "Loading . . .")

GUICtrlSetData($Edit42, "Loading . . .")

GUICtrlSetData($Edit43, "Loading . . .")

GUICtrlSetData($Edit44, "Loading . . .")

GUICtrlSetData($Edit45, "Loading . . .")

$Stock = GUICtrlRead($Input41)

$URL = "https://strade.sharekhan.com/rmmweb/feed/quotes.jsp?scrip=" & $Stock

$ObjIE = ObjCreate("InternetExplorer.Application")

With $ObjIE

.Visible = False

.Navigate ($URL)

Do

Sleep(50)

Until .ReadyState = 4

EndWith

$oIE = _IEAttach($Stock)

$oTable = _IETagNameGetCollection($oIE, "table", 8)

$dTable = _IETableWriteToArray($oTable, True)

;_ArrayDisplay($aTable, "Table index: ")

GUICtrlSetData($Edit41, $dTable[0][1])

GUICtrlSetData($Edit42, $dTable[5][1])

GUICtrlSetData($Edit43, $dTable[8][1])

GUICtrlSetData($Edit44, $dTable[13][1])

GUICtrlSetData($Edit45, $dTable[24][1])

$oIE.quit ()

$begin = TimerInit()

EndFunc ;==>UpdateStock4

;***************************************************************************

;Update the stock 5 info

Func UpdateStock5()

GUICtrlSetData($Edit51, "Loading . . .")

GUICtrlSetData($Edit52, "Loading . . .")

GUICtrlSetData($Edit53, "Loading . . .")

GUICtrlSetData($Edit54, "Loading . . .")

GUICtrlSetData($Edit55, "Loading . . .")

$Stock = GUICtrlRead($Input51)

$URL = "https://strade.sharekhan.com/rmmweb/feed/quotes.jsp?scrip=" & $Stock

$ObjIE = ObjCreate("InternetExplorer.Application")

With $ObjIE

.Visible = False

.Navigate ($URL)

Do

Sleep(50)

Until .ReadyState = 4

EndWith

$oIE = _IEAttach($Stock)

$oTable = _IETagNameGetCollection($oIE, "table", 8)

$eTable = _IETableWriteToArray($oTable, True)

;_ArrayDisplay($aTable, "Table index: ")

GUICtrlSetData($Edit51, $eTable[0][1])

GUICtrlSetData($Edit52, $eTable[5][1])

GUICtrlSetData($Edit53, $eTable[8][1])

GUICtrlSetData($Edit54, $eTable[13][1])

GUICtrlSetData($Edit55, $eTable[24][1])

$oIE.quit ()

$begin = TimerInit()

EndFunc ;==>UpdateStock5

;***************************************************************************

;Close the GUI

Func Terminate()

$o_object = ""

$oIE = ""

$ObjIE = ""

$Ready = ""

$URL = ""

$oTable = ""

$aTable = ""

$bTable = ""

$cTable = ""

$dTable = ""

$eTable = ""

Exit 0

EndFunc ;==>Terminate

Edited by Hatcheda
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...