这个问题与YQL / datatables.org相关的问题是不,有些人声称要在几天前失败,因为YQL在我的案例中做了回应,但问题在于回应字符集,因此解码它。对于像GOOG这样的其他安全标志,过去它的反应非常好。
这是我用来从Yahoo finance API检索“AOJ-P.CO”的股票数据的REST查询:
它给出了以下回应:
{
"query": {
"count": 0,
"created": "2017-05-18T06:54:16Z",
"lang": "en-US",
"diagnostics": {
"url": [
{
"execution-start-time": "0",
"execution-stop-time": "1",
"execution-time": "1",
"content": "http://www.datatables.org/yahoo/finance/quote/yahoo.finance.quote.xml"
},
{
"execution-start-time": "5",
"execution-stop-time": "6",
"execution-time": "1",
"content": "http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
}
],
"publiclyCallable": "true",
"cache": {
"execution-start-time": "3",
"execution-stop-time": "4",
"execution-time": "1",
"method": "GET",
"type": "MEMCACHED",
"content": "5d1e1de680846a307c9874dc3d6878dc"
},
"warning": [
"Unable to decode response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO using utf-8",
"Unable to find valid encoding for response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
],
"query": {
"execution-start-time": "4",
"execution-stop-time": "6",
"execution-time": "2",
"params": "{url=[http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO]}",
"content": "select * from csv where url=@url and columns='Ask,AverageDailyVolume,Bid,AskRealtime,BidRealtime,BookValue,Change&PercentChange,Change,Commission,Currency,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": {
"execution-start-time": "3",
"execution-stop-time": "6",
"execution-time": "3",
"instructions-used": "12000",
"table-name": "yahoo.finance.quote"
},
"user-time": "6",
"service-time": "3",
"build-version": "2.0.118"
},
"results": null
}
}
基本上要注意这一点:
"warning": [
"Unable to decode response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO using utf-8",
"Unable to find valid encoding for response content for http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO"
],
它表示“无法使用utf-8解码响应内容”
我不确定这里有什么问题,但这是一个有效的股票代码,应该给出如下结果: https://in.finance.yahoo.com/quote/AOJ-P.CO?p=AOJ-P.CO
猜测是因为响应中有一些特殊的字符,比如它的名字“BrødreneA& O Johansen A / S”?
但它在响应中提到的quotes.csv中给出了一些结果: http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AOJ-P.CO
但是,如何才能像其他符号(例如“GOOG”)获得此符号的有效回复?这个请求有什么问题?
答案 0 :(得分:0)
在我得到另一个解决方案之前,我发现最好暂时从响应中读取quotes.csv。
这是一个有用的库: https://github.com/dirkolbrich/yahoo-finance-query