Python - Download A Csv File In Website Without Link
I am having problem on downloading a csv file using python. File Location: https://www.hkex.com.hk/eng/sorc/options/statistics_hv_iv.aspx?ucode=00001 The download button 'export to
Solution 1:
From the URL provided you cannot extract the download link directly. However, downloading the CSV yields the following URL:
https://www.hkex.com.hk/eng/sorc/options/statistics_hv_iv.aspx?action=csv&type=3&ucode=00001
. Making it predictable.
So depending on your usecase, you can use that? The values for ucode
can be extracted from select box in your first url.
Solution 2:
Actually, there is a link: https://www.hkex.com.hk/eng/sorc/options/statistics_hv_iv.aspx?action=csv&type=3&ucode=00001
A simple requests.get() call will give you the file:
importrequestsfiledata= requests.get('https://www.hkex.com.hk/eng/sorc/options/statistics_hv_iv.aspx?action=csv&type=3&ucode=00001').text
Post a Comment for "Python - Download A Csv File In Website Without Link"