简体   繁体   English

雅虎财务历史API csv似乎无法开放? JAVA

[英]Yahoo finance historical API csv cannot seem to openstream? JAVA

//URL url =  new URL("http://quote.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv");
URL url =  new URL("http://chart.finance.yahoo.com/table.csv?s=AAPL&a=&b=3&c=2017&d=4&e=1&f=2017&g=d&ignore=.csv");
URLConnection urlConn = url.openConnection();
System.out.println(urlConn.getInputStream().available());

Working in java. 在java工作。

The first url which returns today's data in csv format works fine, returns 70 bytes. 第一个以csv格式返回今天数据的url工作正常,返回70个字节。

However, the second url which return a list of historical data in csv returns 0 bytes. 但是,在csv中返回历史数据列表的第二个url返回0个字节。 This url works fine if opened via browser. 如果通过浏览器打开,此URL工作正常。

What's the difference and how to make it work? 有什么区别以及如何使其发挥作用?

(I've also tried urlConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 4.10; rv:52.0) Gecko/20100101 Firefox/52.0") (我也尝试过urlConn.setRequestProperty(“User-Agent”,“Mozilla / 5.0(Windows NT 4.10; rv:52.0)Gecko / 20100101 Firefox / 52.0”)

Yahoo has disabled automation usage of their finance script so it will only work in browser. 雅虎已禁用其财务脚本的自动化使用,因此它只能在浏览器中使用。 I found an alternative with Java's Desktop library. 我找到了Java桌面库的替代品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM