NSEPython Documentation

Hi Dexter/Aeron,

Hope you are doing well.

Thanks for this wonderful library but I need some help with this. I am able to access it from a local machine but from amazon AWS (AWS Linux/RHEL) servers, I am getting the timeout exception.
Please help me out. Thanks in advance.

Regards,
Kapil Badlani

It is not a problem of Python Request. Nse’s robots.txt has blocked all webservers all together. See here
https://www.nseindia.com/robots.txt

User-agent: *

Disallow: /static/htmls/
Disallow: /static/src/
Disallow: /server/
Disallow: /api/

Sitemap: https://www.nseindia.com/sitemap.xml
Sitemap: https://www.nseindia.com/sitemap-stocks.xml

You can use the curl method and initiate shell commands using Python if you want to do it.

How to get latest weekly expiry date from this module as well as from Aliceblue?

Unsure of Aliceblue.

For weekly expiry, You just need to see the first expiry of any banknifty options.
For monthly expiry, You just need to see the first expiry of any banknifty futures.

Futures are monthly. Options are weekly.

For monthly expiry, Use this function nse_quote_meta() -

symbol = "BANKNIFTY"
symbol_info = nse_quote_meta(symbol,"latest","Fut")
expiry_date = symbol_info['expiryDate']

For weekly expiry, Use this function nse_expirydetails() -

payload = nse_optionchain_scrapper("BANKNIFTY")
currentExpiry,dte=nse_expirydetails(payload)
1 Like

Hey dexter , thankyou for your code and support. Is it possible to make a csv file or a list of the cookies which are used while running the nsepython . Thank you.

Hey dexter , thankyou for your code and support. Is it possible to make a csv file or a list of the cookies which are used while running the nsepython . Thank you.

1 Like

Just copy the nsefetch() function and make another function copying it. I use this method when needed - https://stackoverflow.com/questions/25091976/python-requests-get-cookies