Voy a llamar a la siguiente dirección URL utilizando YQL
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22UTG.L%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=cbfunc
esto devuelve lo siguiente en JSON
cbfunc({"query":{"count":"1","created":"2009-06-27T11:53:44Z","lang":"en-US","updated":"2009-06-27T11:53:44Z","uri":"http://query.yahooapis.com/v1/yql?q=select+*+from+yahoo.finance.quotes+where+symbol+in+%28%22UTG.L%22%29","diagnostics":{"publiclyCallable":"true","url":[{"execution-time":"468","content":"http://datatables.org/alltables.env"},{"execution-time":"634","content":"http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml"},{"execution-time":"351","content":"http://download.finance.yahoo.com/d/quotes.csv?s=UTG.L&f=aa2bb2b3b4cc1c3c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy"},{"execution-time":"357","content":"select * from csv where [email protected] and columns='Ask,AverageDailyVolume,Bid,AskRealtime,BidRealtime,BookValue,Change&PercentChange,Change,Commission,ChangeRealtime,AfterHoursChangeRealtime,DividendShare,LastTradeDate,TradeDate,EarningsShare,ErrorIndicationreturnedforsymbolchangedinvalid,EPSEstimateCurrentYear,EPSEstimateNextYear,EPSEstimateNextQuarter,DaysLow,DaysHigh,YearLow,YearHigh,HoldingsGainPercent,AnnualizedGain,HoldingsGain,HoldingsGainPercentRealtime,HoldingsGainRealtime,MoreInfo,OrderBookRealtime,MarketCapitalization,MarketCapRealtime,EBITDA,ChangeFromYearLow,PercentChangeFromYearLow,LastTradeRealtimeWithTime,ChangePercentRealtime,ChangeFromYearHigh,PercebtChangeFromYearHigh,LastTradeWithTime,LastTradePriceOnly,HighLimit,LowLimit,DaysRange,DaysRangeRealtime,FiftydayMovingAverage,TwoHundreddayMovingAverage,ChangeFromTwoHundreddayMovingAverage,PercentChangeFromTwoHundreddayMovingAverage,ChangeFromFiftydayMovingAverage,PercentChangeFromFiftydayMovingAverage,Name,Notes,Open,PreviousClose,PricePaid,ChangeinPercent,PriceSales,PriceBook,ExDividendDate,PERatio,DividendPayDate,PERatioRealtime,PEGRatio,PriceEPSEstimateCurrentYear,PriceEPSEstimateNextYear,Symbol,SharesOwned,ShortRatio,LastTradeTime,TickerTrend,OneyrTargetPrice,Volume,HoldingsValue,HoldingsValueRealtime,YearRange,DaysValueChange,DaysValueChangeRealtime,StockExchange,DividendYield'"}],"javascript":{"instructions-used":"66024"},"user-time":"1537","service-time":"1810","build-version":"1949"},"results":{"quote":{"symbol":"UTG.L","Ask":"129.00","AverageDailyVolume":"354500","Bid":"128.50","AskRealtime":"129.00","BidRealtime":"128.50","BookValue":"0.00","Change_PercentChange":"+7.50 - +6.19%","Change":"+7.50","Commission":null,"ChangeRealtime":"+7.50","AfterHoursChangeRealtime":"N/A - N/A","DividendShare":"0.00","LastTradeDate":"6/26/2009","TradeDate":null,"EarningsShare":"0.00","ErrorIndicationreturnedforsymbolchangedinvalid":"N/A","EPSEstimateCurrentYear":"0.00","EPSEstimateNextYear":"0.00","EPSEstimateNextQuarter":"0.00","DaysLow":"122.00","DaysHigh":"128.75","YearLow":"36.25","YearHigh":"319.75","HoldingsGainPercent":"- - -","AnnualizedGain":"-","HoldingsGain":null,"HoldingsGainPercentRealtime":"N/A - N/A","HoldingsGainRealtime":null,"MoreInfo":"cred","OrderBookRealtime":"N/A","MarketCapitalization":null,"MarketCapRealtime":null,"EBITDA":"0","ChangeFromYearLow":"+92.50","PercentChangeFromYearLow":"+255.17%","LastTradeRealtimeWithTime":"N/A - <b>128.75<\/b>","ChangePercentRealtime":"N/A - +6.19%","ChangeFromYearHigh":"-191.00","PercebtChangeFromYearHigh":"-59.73%","LastTradeWithTime":"Jun 26 - <b>128.75<\/b>","LastTradePriceOnly":"128.75","HighLimit":null,"LowLimit":null,"DaysRange":"122.00 - 128.75","DaysRangeRealtime":"N/A - N/A","FiftydayMovingAverage":"125.714","TwoHundreddayMovingAverage":"100.63","ChangeFromTwoHundreddayMovingAverage":"+28.12","PercentChangeFromTwoHundreddayMovingAverage":"+27.94%","ChangeFromFiftydayMovingAverage":"+3.036","PercentChangeFromFiftydayMovingAverage":"+2.42%","Name":"UNITE GROUP","Notes":"-","Open":"122.00","PreviousClose":"121.25","PricePaid":null,"ChangeinPercent":"+6.19%","PriceSales":null,"PriceBook":null,"ExDividendDate":"14-Apr-04","PERatio":null,"DividendPayDate":"13-May-05","PERatioRealtime":null,"PEGRatio":null,"PriceEPSEstimateCurrentYear":null,"PriceEPSEstimateNextYear":null,"Symbol":"UTG.L","SharesOwned":null,"ShortRatio":null,"LastTradeTime":"11:35am","TickerTrend":" --=+++ ","OneyrTargetPrice":null,"Volume":"254927","HoldingsValue":null,"HoldingsValueRealtime":null,"YearRange":"36.25 - 319.75","DaysValueChange":"- - +6.19%","DaysValueChangeRealtime":"N/A - N/A","StockExchange":"London","DividendYield":null,"PercentChange":"+6.19%"}}}});
Pero estoy luchando para utilizar los datos (soy un novato con jQuery y JSON) usando
$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22UTG.L%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=cbfunc",
function(data){
de this ejemplo que se acaba parpadea un error URL restringido.
Alguien me ayudo: simplemente tenía que analizar los datos e imprimirlos en la pantalla. ¡Gracias por adelantado!
Gracias compañero, muy apreciado. – toomanyairmiles
De nada :) – moff
Moff, añadí lo siguiente para manejar los datos: - $ each (data.query.results.row, la función (índice, elemento) { $ ('# cotizaciones') .append ( $ ('
') .append ($ (''). text (item.symbol)) .append ($ (''.text('$'+item.price)) ); }); pero recibo 'g no está definido' volviendo en Firebug, ¿alguna idea? – toomanyairmiles