title: Yahoo Finance API Java Download CSV
body: <p>I have been using the Yahoo Finance "API" with the code below for a few weeks.  Since about a week ago, it stopped working.  If you type in this address: <a href="http://ichart.yahoo.com/table.csv?s=MSFT" rel="nofollow noreferrer">http://ichart.yahoo.com/table.csv?s=MSFT</a>, you'll get some historical data for Microsoft (my browser automatically downloads it).  However, when I try to read it through Java, the stream is apparently opened (I don't get an exception), however, the stream contains no data.  Anyone know why the buffered reader below is not able to stream the object as it had been able to do in previous weeks?  I suspect that maybe Yahoo added some java script to block automated downloading.</p>
  
  <pre><code>URL url = new URL("http://ichart.yahoo.com/table.csv?s=" + symbol);
  URLConnection hc = url.openConnection();
  hc.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 4.10; rv:52.0) Gecko/20100101 Firefox/52.0");
  BufferedReader in = new BufferedReader(new InputStreamReader(hc.getInputStream()));
      br.readLine();
      //Read File Line By Line
      String strLine;
      while ((strLine = br.readLine()) != null) {
          System.out.println(strLine);
      }
      br.close();
  </code></pre>