|
<%
if request("post")="true" then
Dim objXML
'create an instance of the XMLHTTP component
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
strURL ="http://quote.yahoo.com/l?m=US&s="&request("company")&"&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
if instr(strOpen,"returned no Stocks") > 0 then
response.write("Your search for '"&request("company")&"' returned no Stocks matches. ")
else
strOpen=replace(strOpen,"View Quotes for All Above Symbols","")
startPoint= InStr(strOpen,"")
startPoint= InStr(startPoint,strOpen," ")
'response.write("strOpen : "&strOpen&" ")
'and this is the end point on the page
endPoint = instr(startPoint,strOpen,"")
'store all of the rest in the variable strYahoo
strYahoo = Mid( strOpen, startPoint, endPoint-startPoint-14 )
'display the part of the page we want
strYahoo=replace(strYahoo,"q?s=","stock_quote.php?symbol=")
strYahoo=replace(strYahoo,"Add to My Portfolio | "," | ")
strYahoo=replace(strYahoo,"Add","")
response.Write strYahoo
end if
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
end if
%>
|
|