Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Get Stock Quote
Vikash Kumar
11/6/2006 11:51:00 AM
class RubyStock
def initialize
end
require 'net/http'
def RubyStock::getStocks(*symbols)
Hash[*(symbols.collect{|symbol|[symbol,Hash[ *(Net::HTTP.get('quote.yahoo.com','/d?f=nl1&s='+symbol).chop .split(',').unshift("Name").insert(2,"Price"))]];}.flatten)];
end
end
myHash = RubyStock::getStocks("IBM","YHOO","RHAT","MSFT","AOL");
myHash.each { |key,value,v1|
print "Symbol is: #{key}...";
print "FullName: #{value['Name']}...";
print "Price: #{value['Price']}\n";
}
It generates the output like
Symbol is: YHOO...FullName: "YAHOO INC"...Price: 26.18
Symbol is: AOL...FullName: "AOL"...Price: 0.00
Symbol is: MSFT...FullName: "MICROSOFT CP"...Price: 28.73
Symbol is: RHAT...FullName: "RED HAT INC"...Price: 16.67
Symbol is: IBM...FullName: "INTL BUSINESS MAC"...Price: 91.41
As we know by appending 'o', 'c', 'v', 'g', 't1', d1' to the URL we can
get opening price, change, high, low, time, date, etc.
But I am unable to get Opening price, change, high, low, time, date etc.
What should be the modification in code to achieve this. Please send me
the code. Thanks in advance.
--
Posted via
http://www.ruby-...
.
2 Answers
Charles L. Snyder
11/6/2006 1:06:00 PM
0
Vikash Kumar wrote:
-------
>
> But I am unable to get Opening price, change, high, low, time, date etc.
> What should be the modification in code to achieve this. Please send me
> the code. Thanks in advance.
>
> --
> Posted via
http://www.ruby-...
.
You need to add the correct tags to your code - the tags are listed
here:
http://www.gummy-stuff.org/Yaho...
eg
http://finance.yahoo.com/d/quotes.csv?s=XOM+BBDb.TO+JNJ+MSFT&f=sn...
CLS
Vikash Kumar
11/8/2006 11:30:00 AM
0
Charles L. Snyder wrote:
> Vikash Kumar wrote:
> -------
>>
>> But I am unable to get Opening price, change, high, low, time, date etc.
>> What should be the modification in code to achieve this. Please send me
>> the code. Thanks in advance.
>>
>> --
>> Posted via
http://www.ruby-...
.
>
> You need to add the correct tags to your code - the tags are listed
> here:
>
http://www.gummy-stuff.org/Yaho...
>
> eg
>
http://finance.yahoo.com/d/quotes.csv?s=XOM+BBDb.TO+JNJ+MSFT&f=sn...
>
> CLS
Thanks it really works for me
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Get Stock Quote
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password