//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.
The first url which returns today's data in csv format works fine, returns 70 bytes.
However, the second url which return a list of historical data in csv returns 0 bytes. This url works fine if opened via browser.
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")
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.