Pergunta

How would I do a YQL /v1/yql query for the price of a given stock. Just the price, in html.

I have read everything on their developer page but it is not very clear.

Thanks!

Foi útil?

Solução

You have to use it as web service. Just make the correct query syntax to pass as parameter in the URL. Then you will get result in XML format.

This is a public URL to access public data which does not require authorization:

http://query.yahooapis.com/v1/public/yql

You have make a symbol list for stock you want to query and put them in the querying command. Here is a sample command to query YHOO, AAPL, GOOG and MSFT quotes

select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")

Then you have to pass parameter q with value as a query command such below:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%20%28%22YHOO%22%2C%22AAPL%22%2C%22GOOG%22%2C%22MSFT%22%29&diagnostics=true&env=http%3A%2F%2Fdatatables.org%2Falltables.env

To make it better in the URL, I replaced space with "%20", brackets with "%28" and "%29", double quote with "%22", comma with "%2C", colon with "%3A" and slash with "%2F".

Notice that I also pass other parameters as well, which are

diagnostics=true and env=http://datatables.org/alltables.env

I hope this will help.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top