Currently, I can get stock quote by returning xml and json using YQL console like
select symbol, price from csv where url=’http://download.finance.yahoo.com/d/quotes.csv?s=IBM,YHOO,GOOG,MSFT&f=sl1d1t1c1ohgv&e=.csv’ and columns=’symbol,price,date,time,change,col1,high,low,col2′
I would like to get the complete component list from
http://download.finance.yahoo.com/d/quotes.csv?s=@^HSI&f=sl1d1t1c1ohgv&e=.csv
using YQL console, so I input the statement below in YQL console
select symbol, price from csv where url=’http://download.finance.yahoo.com/d/quotes.csv?s=@^HSI&f=sl1d1t1c1ohgv&e=.csv’ and columns=’symbol,price,date,time,change,col1,high,low,col2′
but it said my link is invalid. Any thoughts and alterative solutions?
Your query was very nearly correct, but the URL was considered “invalid” as you noted. The solution is to properly escape the query string values.
becomes
Changing just those two characters into their %-encoded values allows YQL to pull back the CSV data.
Aside: YQL doesn’t like that the CSV has an empty line at the end of the file, this will cause issues when you try to use the
columnswhere clause. If you’re okay with having the columns calledcol<number>and want to skip the last (empty) row then useand col8 is not nullat the end of your query.