Jump to content


< Back to Forum


 

Internet Portal Script Not Playing Correct Quotes


  • Please log in to reply

#1 czardoff 10 June 2015 - 10:46 AM

I'm having a problem with the Internet Portal sample script where when it runs, it repeats: "The Dow is trading at ZERO. The Nasdaq is trading a ZERO. The S&P is trading at ZERO."
 
I don't know if this is a vbscript code error or if finance.yahoo.com changed something on their page since this vbscript sample code was written.
 
Do you know what's happening in this situation? Please determine the accuracy of the sample and provide any fixes. Below is original Voiceguide internet portal vbscript.
 
I am running vg 6.0.3991  Enterprise+Dialer
--- 
 
if 1 then
'preferred approach is:
'connect and retrieve data by using XMLHTTP object

Set objXMLHTTP = CreateObject("microsoft.XMLHTTP")
objXMLHTTP.Open "GET", "http://finance.yahoo.com", False
objXMLHTTP.Send
If objXMLHTTP.Status <> 200 Then
readWwwText = ""
else
readWwwText = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
end if

else
'another approach is:
'connect and retrieve data by starting up another instance of InternetExplorer

Set IE = CreateObject("InternetExplorer.Application")
With IE
.RegisterAsDropTarget = False
.Visible = False
.Silent = True
.Navigate("finance.yahoo.com")
While .Busy
WScript.Sleep 100
Wend
With .Document.Body
readWwwHtml = .InnerHTML
readWwwText = .InnerText
End With
End With
IE.Quit
Set IE = Nothing

end if


'iIndexDow = GetIntegerAfterLabel("Dow</a>")
'iIndexNasdaq = GetIntegerAfterLabel("Nasdaq</a>")
'iIndexSP500 = GetIntegerAfterLabel("P 500</a>")

iIndexDow = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^dji"">")
iIndexNasdaq = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^ixic"">")
iIndexSP500 = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^gspc"">")



strResultVariables= "[MarketDow]{" & iIndexDow & "}" & _
"[MarketNasdaq]{" & iIndexNasdaq & "}" & _
"[MarketSP500]{" & iIndexSP500 & "}"

'make sure the returned data does not contain any commas
strResultVariables = replace(strResultVariables, ",", "")

set vg = CreateObject("VoiceGuide.CommandLink")
vg.Run_ResultReturn $RV_DEVICEID, strResultVariables
Set vg = Nothing


function GetIntegerAfterLabel(strLabel)
'it is assumed that the integer terminates with a decimal point
iLblPos1= Instr(readWwwText, strLabel)
iValuePos1 = iLblPos1 + len(strLabel)
iValuePos2 = Instr(iValuePos1, readWwwText, ".")
strAfterLabel = mid(readWwwText, iValuePos1, iValuePos2-iValuePos1)
'msgbox strAfterLabel
'now remove everything except the digits.
for i = 1 to len(strAfterLabel)
ch = mid(strAfterLabel, i, 1)
if ch >= "0" and ch <= "9" then
GetIntegerAfterLabel = GetIntegerAfterLabel & ch
end if
next
end function


#2 SupportTeam 10 June 2015 - 11:14 AM

That particular example shows how to 'scrape' information from a web page.

 

In VoiceGuide v7 there is a "Web Service" module ( http://www.voiceguid.../html/modws.htm ) that would let you attach to Web Services instead of scraping web pages for information.

 

Looks like finance.yahoo.com web page contents have changed since the example that you are trying to run was released, but looking at that web page contents we can see that the information is still there.

 

Looking at the finance.yahoo.com source text we can see that following modifications would need to be made to this sample script to make it work:

 

change:

 

iIndexDow = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^dji"">")
iIndexNasdaq = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^ixic"">")
iIndexSP500 = GetIntegerAfterLabel("<span class=""streaming-datum"" id=""yfs_l10_^gspc"">")

 

to:

 

iIndexDow = GetIntegerAfterLabel("<span id=""yfs_l84_^dji"" class=""l84"">")
iIndexNasdaq = GetIntegerAfterLabel("<span id=""yfs_l84_^ndx"" class=""l84"">")
iIndexSP500 = GetIntegerAfterLabel("<span id=""yfs_l84_^gspc"" class=""l84"">")