我正在处理雅虎股票数据。昨天我通过使用财务网络服务api获得了股票数据。但今天当我试图从api获取数据时,我收到以下错误:
{
"p": {
"a": {
"href": "https://finance.yahoo.com/webservice/v1/symbols/msft,goog,appl,orcl,yhoo,tcs,amzn,INFY.NS/quote?bypass=true&format=json&view=detail",
"content": "https://finance.yahoo.com/webservice/v1/symbols/msft,goog,appl,orcl,yhoo,tcs,amzn,INFY.NS/quote?bypass=true&format=json&view=detail"
},
"content": "Moved Temporarily. Redirecting to"
}
}
说它暂时移动了。
为什么我收到此错误?我今天达到了API限制吗?
注意:
昨天我一直在运行以测试API请求限制。但是当我今天试图运行它时会显示上述错误。
如果达到IP的API限制,那么我何时可以再次访问数据? 这是我正在使用的API:
http://finance.yahoo.com/webservice/v1/symbols/msft,goog,appl,orcl,yhoo,tcs,amzn,INFY.NS/quote?format=json&view=detail
答案 0 :(得分:1)
正如在此处评论的那样:https://stackoverflow.com/a/38390559/6586718,您必须将用户代理更改为移动设备。
在Java上,我执行以下操作,它正在运行(这适用于XML,但同样可以应用于JSON):
URL url = new URL ("https://finance.yahoo.com/webservice/v1/symbols/" + stocks + "/quote");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection ();
urlc.setRequestProperty ("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; MotoE2(4G-LTE) Build/MPI24.65-39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537.36");
Document xml = DocumentBuilderFactory.newInstance ().newDocumentBuilder ().parse (urlc.getInputStream ());
答案 1 :(得分:0)
尝试使用这个新的..
https://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2FD%2Fquotes.csv%3FS%3DAAPL%26F%3Dsl1d1t1c1ohgv%26E% 3D.csv '%20于是%20columns%3D'symbol%2Cprice%2Cdate%2Ctime%2Cchange%2Ccol1%2Chigh%2Clow%2Ccol2' 和;格式= JSON&安培; ENV =商店%3A%2F%2Fdatatables.org%2Falltableswithkeys