I am trying to download a CSV file from morningstar using python. here is the link: http://financials.morningstar.com/income-statement/is.html?t=NAB®ion=aus
There is a button to "export CSV" but I can't access the link.
There is this javascript:exportKeyStat2CSV(); but I am not sure how to find the URL of the CSV file?
I tried to download the file and get the URL to use requests/panadas to download the file but requests/panadas cant get anything.
import pandas as pd
URL= ("http://financials.morningstar.com/finan/ajax/exportKR2CSV.html?&callback=?&t=XASX:NAB®ion=aus&culture=en-US&cur=&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!")
I get Requests 204 code.
How do I solve the problem?