Download NSE 2021 data using Python

时光总嘲笑我的痴心妄想 提交于 2021-01-29 08:25:51

问题


I'm facing issue to access such URL via Python code

https://www1.nseindia.com/content/historical/EQUITIES/2021/JAN/cm01JAN2021bhav.csv.zip

This was working for last 3 years until 31-Dec-2020. Seems that the site has implemented some restrictions. There's solution for similar one here in

VB NSE ACCESS DENIED This addition is made : "User-Agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11" "Referer" : "https://www1.nseindia.com/products/content/equities/equities/archieve_eq.htm"

Original code is here : https://github.com/naveen7v/Bhavcopy/blob/master/Bhavcopy.py

It's not working even after adding following in requests section

 headers = {'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11'}
            ##print (Path)
            a=requests.get(Path,headers)  

Can someone help?

来源:https://stackoverflow.com/questions/65810950/download-nse-2021-data-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!