Skip to content

Commit

Permalink
market data
Browse files Browse the repository at this point in the history
  • Loading branch information
katmakhan committed Oct 24, 2023
1 parent d80b0e5 commit 64a031e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Binary file not shown.
Binary file added NSE Market Data/.DS_Store
Binary file not shown.
42 changes: 42 additions & 0 deletions NSE Market Data/get_json_cookie_bypass_FNO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#For invoking http requests
import requests

#Json Parsing
import json


def main():
#Fetching NIFTY Stocks
# actualurl='https://www.nseindia.com/api/liveEquity-derivatives?index=top20_contracts'
actualurl='https://www.nseindia.com/api/liveEquity-derivatives?index=stock_opt'

#Visit the main page to bypass cookies
s = requests.Session()


headers = {
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.5",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}


# To set the cookies
mainurl = "https://www.nseindia.com/"
response = s.get(mainurl,headers=headers,timeout=2)

#Then visit the json page for fetching the json
res = s.get(actualurl,headers=headers,timeout=2)
print(res.json())

fnolistdata=res.json()['data']
# print(fnolistdata)

for data in fnolistdata:
symbol=data['identifier']
print(symbol)



#Main program
if __name__ == '__main__':
main()

0 comments on commit 64a031e

Please sign in to comment.