Briand9 wrote:Has anyone figured out a way to write an applescript that gets stock prices? I looked extensively online, and found several scripts, and even tried the apple provided one in the script menu, but none worked. I couldn't even get them to work outside Indigo. Does anyone have any idea? I assume I would have to use SOAP? But I have never used it. Thanks.
-- This script looks up the delayed stock quote for "AAPL" on the web.
-- Requires an active connection to the Internet.
-- To customize this script for looking up a different stock quote, replace the symbol ("AAPL") below with the appropriate value.
-- Portions of this script courtesy of Apple Computer, Inc.. See sample scripts in /Library/Scripts/Internet Services/ for more details.
property SOAP_Endpoint_URL : "http://services.xmethods.net:80/soap"
property SOAP_app : "soap"
property method_name : "getQuote"
property method_namespace_URI : "urn:xmethods-delayed-quotes"
property SOAP_action : ""
on do_action given call:c, callername:n, callerid:cid, tonesequence:seq
set this_text to "AAPL"
set the method_parameters to {symbol:this_text}
copy my SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action) to {call_indicator, call_result}
tell application "Ovolab Phlink.app"
tell c
if the call_indicator is false then
«event miscSpk » "An error occurred." & return & return & call_result
else
«event miscSpk » "The stock quote for " & this_text & " is: " & call_result & " dollars."
end if
end tell
end tell
end do_action
on SOAP_call(SOAP_Endpoint_URL, method_name, method_namespace_URI, method_parameters, SOAP_action)
try
with timeout of 10 seconds
using terms from application "http://www.apple.com/placebo"
tell application SOAP_Endpoint_URL
set this_result to call soap ¬
{method name:method_name ¬
, method namespace uri:method_namespace_URI ¬
, parameters:method_parameters ¬
, SOAPAction:SOAP_action}
end tell
end using terms from
return {true, this_result}
end timeout
on error error_message number error_number
if the error_number is -916 then ¬
set the error_message to "The script was unable to establish a connection to the Internet."
return {false, error_message}
end try
end SOAP_call
tell application "IndigoServer"
set value of variable "AppleStock" to call_result as string
end tell
Briand9 wrote:Thanks to Matt, I finally had a moment to download the web scripts folder he mentioned. I found the script file I need, but am having trouble modifying it. I am not using ovolab phlink at all, but hoped to use the first part of the script to call the stock quote or a set stock or a indicator (DJIA, NASDAQ etc).
tell application "IndigoServer"
set value of variable "AppleStock" to do shell script "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=l1'"
end tell
tell application "IndigoServer"
set value of variable "AppleStock" to do shell script "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=l1'"
end tell
Users browsing this forum: No registered users and 24 guests