#21042 - 2002-05-01 11:01 PM
Stock Prices in Login script
|
JackS
Lurker
Registered: 2002-05-01
Posts: 2
|
Has anyone figured out how to put the current stock price of a corp in a login script that's updated from the Internet???
|
|
Top
|
|
|
|
#21044 - 2002-05-01 11:21 PM
Re: Stock Prices in Login script
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
didn't Shawn have something like that?
|
|
Top
|
|
|
|
#21045 - 2002-05-01 11:47 PM
Re: Stock Prices in Login script
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Yeah, we were using this to check-up on Bryce's numerous osh:x stock options:
Topic: OLE/IE Stock Quotes - The inner beauty of innerHTML
But this script sure could benefit from a 4.0 make-over I'll tell yeah.
-Shawn
p.s. I haven't actually run this script to see if it still works. It did work ! But you know how web-sites are, changing just for the sake of changing ... [ 02 May 2002, 00:04: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#21046 - 2002-05-02 02:39 PM
Re: Stock Prices in Login script
|
JackS
Lurker
Registered: 2002-05-01
Posts: 2
|
quote: what version of kix? and what is the stock and or web page you are pulling info from?
Bryce The version of KIX is 2001.402 The stock is SVM I not sure where to get to price quote from to be honest.
|
|
Top
|
|
|
|
#21047 - 2002-05-02 02:56 PM
Re: Stock Prices in Login script
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Jack,
I just did a quicky conversion of the aforementioned script. It queries my own discount brokerage here in Canada. You run it like this:
C:\>kix32 quote $stock=SVM $exchange=x
Here's the source:
QUOTE.KIX
break on
; ; SCRIPT: quote.kix ; ; USAGE: kix32 quote $stock=symbol $exchange=exchange ; ; EXAMPLE: kix32 quote $stock=brk.b $exchange=x (Berkshire Hathaway on New York) ; EXAMPLE: kix32 quote $stock=td $exchange=t (Toronto Dominion Bank on Toronto) ; ; Submits a cgi request and parses returned html for information... ; ; Check command line parameters & set defaults ...
if $stock else $stock = "BRK.B" endif
if $exchange else $exchange = "X" endif
$URL = 'http://www.bmoinvestorline.com/cgi-bin/t3i.3.cgi/e/ilmquote.taf?textfield=$stock&Exchange=$exchange' $PARSE1 = 'Last: ' $CRLF = CHR(13)+CHR(10)
?"Searching "
$ie = createobject("internetexplorer.application") "."
$ie.navigate($URL) "."
while $ie.readystate <> 4 and $ie.busy and @error = 0 loop "."
while $ie.document.readystate <> "complete" and @error = 0 loop "."
$html = $ie.document.documentelement.innerhtml
$len = len("$html") $pos = instr("$html", "$PARSE1" )
if $pos
$pos = $pos + len("$PARSE1") $html = substr("$html", $pos, $len) $price = substr("$html",1,instr("$html"," ")-1)
? ?"$stock:$exchange = $price" ?
else
?"Error getting stock quote"
endif
; Cleanup ...
$ie.quit $ie = 0 exit 1
I guess the other way you might consider doing this is to create a DAT or INI file on a share somewhere, then build a tool that updates this dat file (batch job), then query this file in your login scripts. Might be faster and easier to maintain.
-Shawn [ 02 May 2002, 14:57: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#21049 - 2003-05-14 05:32 AM
Re: Stock Prices in Login script
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Shawn
Still works for me as well.
DIS:X = 18.50
|
|
Top
|
|
|
|
#21050 - 2004-11-01 10:29 PM
Re: Stock Prices in Login script
|
singk
Fresh Scripter
Registered: 2002-02-14
Posts: 31
|
When I ran this script, I got this error message.
kix32 quote.kix $stock=drra Exchange=x
Searching .... ERROR : expression too long! Script: H:\Netlogon\UDF\quote.KIX Line : 41
Does anyone has any idea?
Thanks Singk
_________________________
Thanks,
Sing
|
|
Top
|
|
|
|
#21055 - 2004-11-02 02:13 PM
Re: Stock Prices in Login script
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Ok, just needed a tweak and a poke ...
Code:
break on
; ; SCRIPT: quote.kix ; ; USAGE: kix32 quote $stock=symbol $exchange=exchange ; ; EXAMPLE: kix32 quote $stock=brk.b $exchange=x (Berkshire Hathaway on New York) ; EXAMPLE: kix32 quote $stock=td $exchange=t (Toronto Dominion Bank on Toronto) ; ; Submits a cgi request and parses returned html for information... ; ; Check command line parameters & set defaults ...
if $stock else $stock = "BRK.B" endif
if $exchange else $exchange = "X" endif
$URL = 'http://www.bmoinvestorline.com/cgi-bin/t3i.3.cgi/e/ilmquote.taf?textfield=$stock&Exchange=$exchange' $PARSE1 = 'Last: ' $CRLF = CHR(13)+CHR(10)
?"Searching "
$ie = createobject("internetexplorer.application") "."
$ie.navigate($URL) "."
while $ie.readystate <> 4 and $ie.busy and @error = 0 loop "."
while $ie.document.readystate <> "complete" and @error = 0 loop "."
$html = $ie.document.documentelement.innerhtml
$len = len($html) $pos = instr($html, $PARSE1)
if $pos
$pos = $pos + len("$PARSE1") $html = substr($html, $pos, $len) $price = substr($html,1,instr($html," ")-1)
? ?"$stock:$exchange = $price" ?
else
?"Error getting stock quote"
endif
; Cleanup ...
$ie.quit $ie = 0 exit 1
-Shawn
|
|
Top
|
|
|
|
#21056 - 2004-11-02 02:28 PM
Re: Stock Prices in Login script
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Tidied up a bit, simplified a bit, "explicit" safe, "novarsinstrings" safe, short form hungarian'ed... Code:
Break ON $=SetOption("WrapAtEOL","ON") $=SetOption("ASCII","ON") $=SetOption("Explicit","ON")
; ; SCRIPT: quote.kix ; ; USAGE: kix32 quote $sStock=symbol $sExchange=exchange ; ; EXAMPLE: kix32 quote $sStock=brk.b $sExchange=x (Berkshire Hathaway on New York) ; EXAMPLE: kix32 quote $sStock=td $sExchange=t (Toronto Dominion Bank on Toronto) ; ; Submits a cgi request AND parses returned html for information... ; Dim $oIE,$sSentinel,$sURL,$sLine If Not IsDeclared($sStock) Global $sStock EndIf If Not IsDeclared($sExchange) Global $sExchange EndIf ; Check commAND line parameters & set defaults ... If Not $sStock $sStock = "BRK.B" EndIf if Not $sExchange $sExchange = "X" EndIf $sURL = 'http://www.bmoinvestorline.com/cgi-bin/t3i.3.cgi/e/ilmquote.taf?textfield='+$sStock+'&Exchange='+$sExchange $sSentinel = 'Last: ' $oIE = createobject("internetexplorer.application") $oIE.navigate($sURL) While $oIE.readystate <> 4 AND $oIE.busy AND @error = 0 Loop While $oIE.document.readystate <> "complete" AND @error = 0 Loop For Each $sLine in Split($oIE.document.body.innerText,@CRLF) If InStr($sLine,$sSentinel) $sLine ? EndIf Next $oIE.quit $oIE = 0 exit 0
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|