title: How to download a csv file from internet when there is javascript button?
body: <p>I am trying to download a CSV file from morningstar using python. 
  here is the link:
  <a href="http://financials.morningstar.com/income-statement/is.html?t=NAB&amp;region=aus" rel="nofollow noreferrer">http://financials.morningstar.com/income-statement/is.html?t=NAB&amp;region=aus</a></p>
  
  <p>There is a button to "export CSV" but I can't access the link. </p>
  
  <p>There is this javascript:exportKeyStat2CSV(); but  I am not sure how to find the URL of the CSV file?</p>
  
  <p>I tried to download the file and get the URL to use requests/panadas to download the file but requests/panadas cant get anything. </p>
  
  <pre><code>import pandas as pd
  URL= ("http://financials.morningstar.com/finan/ajax/exportKR2CSV.html?&amp;callback=?&amp;t=XASX:NAB&amp;region=aus&amp;culture=en-US&amp;cur=&amp;order=asc")
  
  df=pd.read_csv(URL) ( didnt work with pandas)
  
  
  import requests
  
  print ('Starting to Download!')
  
  
  r = requests.get(URL)
  
  filename = url.split('/')[-1]
  
  with open(filename, 'wb') as out_file:
      out_file.write(r.content)
  
  print("Download complete!")
  </code></pre>
  
  <p>I get Requests 204 code.</p>
  
  <p>How do I solve the problem?</p>