Page 1 of 1

Getting a stock quote

Posted: Wed Nov 19, 2008 2:19 am
by petero
Can someone help me get started with creating a Rev app that lets you enter a company symbol (e.g. IBM) and then retrieves the previous day's price for that stock by going to an internet site or using an RSS feed?

I am a teacher helping a student with a project.

Thanks in advance.

Posted: Wed Nov 19, 2008 9:57 am
by Mark
Hi Petero,

Can you post a link to such a site or feed?

Best,

Mark

Example of where to get a stock quote

Posted: Wed Nov 19, 2008 4:01 pm
by petero
There are many sites that let you enter a stock symbol and return the price.

For example,

http://www.quoterss.com/

There many be others that are in a format better suited for use with Revolution.

More Sources for stock quotes

Posted: Wed Nov 19, 2008 4:05 pm
by petero
Here are some other possibilities for entering ticker data and getting a stock price.

http://www.nasdaq.com/

http://www.smartmoney.com/rss/

http://www.2rss.com/rss_8072.html

Posted: Wed Nov 19, 2008 4:22 pm
by Mark
Hi petero,

The links that you posted don't provide any data. It is just a website with a form. You need to find a link that actually provides the data. I don't know what to enter in those forms. If you check out how the forms work, you may be able to figure out how to compose a URL or data to post to the CGI.

In the mean time you can do this:

Code: Select all

set the htmlText of fld 1 to url"http://2RSS.com/rss2html.php?rss_url=http://www.googlestockquote.com/feed/rss2/"
If you don't like this, you could put the data from the url into a variable and parse it. You could also handler the data correctly, as XML. There is a tutorial that explains exactly how to do this here and the stack accompanying the article is here.

Best regards,

Mark

More details

Posted: Thu Nov 20, 2008 1:03 am
by petero
Thanks so much for taking the time to help out.

If you go to

http://www.quoterss.com/

and enter IBM into the quote box, and press "Generate RSS feed", a URL appears that, when entered, displays exactly what I would like ... the number indicating the price.

Can Revolution parse through this to get that number?

Posted: Thu Nov 20, 2008 1:48 am
by Mark
Hi Petero,

I tried the following script in a button:

Code: Select all

on mouseUp
   --set the httpHeaders to "User-Agent: Mozilla/5.0"
   put url "http://www.quoterss.com/details.php?symbol=ibm&frmt=txt&Freq=0" into myHtml
   -- now you could parse the data
   put myHtml -- show in message box
end mouseUp
First, I tried it without setting the httpHeaders. This line is commented out in the script above. This didn't work. I got a meaningless page about how cool Google shares are. Then I suscribed to the RSS feed, using Apple Mail. This worked. Now I decided to set the httpHeaders (uncomment that line in the script above) and everything worked as expected. I am not sure what the effect of setting the httpHeaders is, but you can try. What do you get in the message box? it should start with "<title>QuoteRSS.com: IBM</title>" and continue with the HTML code for a table.

I tried several formats. Regardless of what I choose on the website, I always get the same URL. I also tried changing frmt=0 into frmt=1 and other numbers, but this didn't work. I even tried frmt=csv et cetera, without result.

Once you get this working, you can write your own script to parse the table, or you could set the htmlText of a field to myHtml.

Best,

Mark