Page 1 of 1 1
Topic Options
#21042 - 2002-05-01 11:01 PM Stock Prices in Login script
JackS Offline
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
#21043 - 2002-05-01 11:17 PM Re: Stock Prices in Login script
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
interesting.......

what version of kix? and what is the stock and or web page you are pulling info from?

Top
#21044 - 2002-05-01 11:21 PM Re: Stock Prices in Login script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
didn't Shawn have something like that?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#21045 - 2002-05-01 11:47 PM Re: Stock Prices in Login script
Shawn Administrator Offline
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 Offline
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 Offline
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
#21048 - 2002-05-02 02:59 PM Re: Stock Prices in Login script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Oh yeah, almost forgot, this is what I got when I ran it against your stock:

C:\>kix32 quote $stock=SVM $exchange=X

Searching ....

SVM:X = 14.04

-Shawn

*cha-ching*

[ 02 May 2002, 15:00: Message edited by: Shawn ]

Top
#21049 - 2003-05-14 05:32 AM Re: Stock Prices in Login script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
[Cool] 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 Offline
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
#21051 - 2004-11-01 11:27 PM Re: Stock Prices in Login script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I don't get any error, but I don't get a response from that server right now either.

This link is now about 18 months old and might not be valid anymore, or the query method may have changed.

Top
#21052 - 2004-11-02 01:32 AM Re: Stock Prices in Login script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You also forgot the $-sign in front of the "Exchange" variable.
_________________________
There are two types of vessels, submarines and targets.

Top
#21053 - 2004-11-02 05:13 AM Re: Stock Prices in Login script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Okay at home I was able to confirm your error. The site is still up and the URL is still correct, but I get this error.

ERROR : expression too long!
Script: D:\SCRIPTS\quote.kix
Line : 42

That line of code is:
$len = len("$html")

Top
#21054 - 2004-11-02 01:54 PM Re: Stock Prices in Login script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
My discount brokerage went through a web-site re-design little while ago, so I guess the HTML stream got bigger or changed. Will have a boo.
Top
#21055 - 2004-11-02 02:13 PM Re: Stock Prices in Login script
Shawn Administrator Offline
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: &nbsp;'
$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,"&nbsp")-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 Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.078 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org