|
Ticker symbol Lookup
In previous examples we have either searched for
a stock manually or allowed a user to enter a symbol and displayed
thequotes for that symbol . What if we dont know the symbol
though , if you enter Microsoft you wont see the quotes as you
havent entered a valid symbol , in fact you have to enter msft
. This example may help , we are searching for yahoo's ticker
symbol . Once again you will require the XMLHTTP component to
be properly installed on your server / machine.
This example shows the US stock market symbol
to locate symbols worldwide change the url in strURL to strURL="http://quote.yahoo.com/l?m=&s=yahoo&t="
Code :
<%
Dim objXML
'create an instance of the XMLHTTP component
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
strURL ="http://quote.yahoo.com/l?m=US&s=yahoo&t="
'get the strURL
objXML.Open "GET" , strURL , False ,"",""
'send the information
objXML.Send
'if we have no errors
If Err.Number = 0 Then
'and the url is valid
If objXML.Status = 200 then
strOpen = objXML.ResponseText
'this is the start point on the page that we want
startPoint= InStr( strOpen, "<table border=1 cellPadding=4
cellSpacing=0" )
'and this is the end point on the page
endPoint = InStr( startPoint, strOpen, "<small>Add</small>")
'store all of the rest in the variable strYahoo
strYahoo = Mid( strOpen, startPoint, endPoint-startPoint )
'display the part of the page we want
response.Write strYahoo
Else
'bad url display a message
Response.Write "Incorrect URL"
End if
Else
'if we do have an error display the description of the error
Response.Write Err.Description
End If
'clear up
Set objXML = Nothing
%>
|