Sheehan Alam
Sheehan Alam

Reputation: 60889

Help creating a YQL Query to search companies

How can I create a YQL Query that will return me companies from Yahoo Finance?

select * from yahoo.finance.quotes where name like "apple"

Doesn't work.

Upvotes: 1

Views: 2646

Answers (3)

Priyank Joshi
Priyank Joshi

Reputation: 400

To get a symbol of any company you can use the below url :

http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=<company name>&callback=YAHOO.Finance.SymbolSuggest.ssCallback

here in the query you can pass any company name that you want the symbol for.

And then to get the stock details about that symbol you can use the below query :

select * from csv where url="http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sohgpl1&s=<stock symbol>";

here you need to pass the symbol in the comparison with 's'..

So for getting the apple stock information you need to do the following :

http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=apple&callback=YAHOO.Finance.SymbolSuggest.ssCallback

and after getting symbol for apple go for :

select * from csv where url="http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sohgpl1&s=AAPL";

Hope this will be useful..Happy Coding..

Upvotes: 2

Phil Helix
Phil Helix

Reputation: 3723

That won't work for many reasons. Please try:

select * from html where url="http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=snl1d1t1ohgdr"

To get exactly what you want, you could further filter with xpath in the where clause.

Upvotes: 1

spier
spier

Reputation: 2752

Instead of using XPATH I would rather recommend to use the build in CSV datatable and to do something like this:

select * from csv where url='http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=snl1d1t1ohgdr'

The problem with either approach is though that you need to know the stock symbol, so AAPL in this example. So neither my nor the other answer really fulfills your need in terms of being able to search for companies by name.

Don't have more input than this currently, sorry.

Upvotes: 0

Related Questions