Home > Back-end >  Unable to download csv file from iShares website
Unable to download csv file from iShares website

Time:05-12

all by using the code below (link checked, it is correct) I get an HTML file as a result instead of .csv if I were to use a browser like Chrome.

import urllib.request
urllib.request.urlretrieve('https://www.ishares.com/us/products/239726/ishares-core-sp-500-etf/1467271812596.ajax?filetype=csv&filename=ivv_holdings&datatype=fund', "file.csv")

What would be a good solution to this?

CodePudding user response:

THe problem is you have not been careful about the spelling. You have filename, filetype and datatype, whereas the site requires fileName, fileType, and dataType. The capitalization must match.

  • Related