开发者

Help creating a YQL Query to search companies

How can I create a Y开发者_Python百科QL Query that will return me companies from Yahoo Finance?

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

Doesn't work.


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..


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜