Closed pratham-darooka closed 3 months ago
Can you please specify how fast you are looping in requests per minute?
@mdtanveer how fast should i be? I add a time.sleep(1)
@pratham-darooka you are not going to get much help on this here..since it is not much of authors' problem, so he does not care .. look at https://github.com/aeron7/nsepython/pull/41 and https://github.com/aeron7/nsepython/pull/40 and https://github.com/aeron7/nsepython/pull/37
I would suggest you try this below alternate solution, that is, if you are simply trying to get the index constituents of Nifty 50
from io import StringIO
import pandas as pd
import requests
def get_nse_index_json_constituents(json_blob_url: str) -> list:
nse_headers = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36',
'accept-language': 'en,gu;q=0.9,hi;q=0.8',
'accept-encoding': 'gzip, deflate, br'
}
response = requests.get(json_blob_url, headers=nse_headers)
response_bytes = response.content
response_str = response_bytes.decode('utf-8')
return sorted(pd.read_json(StringIO(response_str)).symbol.tolist())
index_constituents = get_nse_index_json_constituents("https://iislliveblob.niftyindices.com/jsonfiles/HeatmapDetail/FinalHeatmapNIFTY%2050.json")
index_constituents will be a list for any further iterations you need.
Tried
nsefetch(“https://www.nseindia.com/api/equity-stockIndices?index=NIFTY%2050”)
in a loop.Output:
b'<HTML><HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD><BODY>\n<H1>Access Denied</H1>\n \nYou don\'t have permission to access "http://www.nseindia.com/api/equity-stockIndices?" on this server.<P>\nReference #18.5c01d517.1715925139.41f263\n<P>https://errors.edgesuite.net/18.5c01d517.1715925139.41f263</P>\n</BODY>\n</HTML>\n’