Open Priyajit-Ghosh opened 7 months ago
same error i'm getting. did you got solution
The links are broken in the lib, they are redirected to the home page of nseindia.com.
looks cookies or header not set
q = nse.get_quote('infy') Traceback (most recent call last): File "
", line 1, in File "C:\Python\Python312\Lib\site-packages\nsetools\nse.py", line 152, in get_quo if self.is_valid_code(code): ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\site-packages\nsetools\nse.py", line 138, in is_vali stock_codes = self.get_stock_codes() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\site-packages\nsetools\nse.py", line 117, in get_sto res = self.opener.open(req) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 553, in error result = self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 745, in http_error_302 return self.parent.open(new, timeout=req.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 553, in error result = self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 745, in http_error_302 return self.parent.open(new, timeout=req.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 559, in error return self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 639, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden nse.get_index_list() Traceback (most recent call last): File " ", line 1, in File "C:\Python\Python312\Lib\site-packages\nsetools\nse.py", line 276, in get_ind resp = self.opener.open(req) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 553, in error result = self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 745, in http_error_302 return self.parent.open(new, timeout=req.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 553, in error result = self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 745, in http_error_302 return self.parent.open(new, timeout=req.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 521, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 630, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 559, in error return self._call_chain(args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain result = func(args) ^^^^^^^^^^^ File "C:\Python\Python312\Lib\urllib\request.py", line 639, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
import sys sys.path.insert(0,"~/python_packages") from nsetools import Nse import pandas as pd, numpy as np
nse = Nse() print(nse) q = nse.get_quote('infy')
giving following errors:=- priyajit@priyajit-IdeaPad-3-15ITL6:~/Documents/Trading code$ python3 fetch_test.py Driver Class for National Stock Exchange (NSE) Traceback (most recent call last): File "fetch_test.py", line 8, in
q = nse.get_quote('infy')
File "/home/priyajit/.local/lib/python3.8/site-packages/nsetools/nse.py", line 152, in get_quote
if self.is_valid_code(code):
File "/home/priyajit/.local/lib/python3.8/site-packages/nsetools/nse.py", line 138, in is_valid_code
stock_codes = self.get_stock_codes()
File "/home/priyajit/.local/lib/python3.8/site-packages/nsetools/nse.py", line 117, in get_stock_codes
res = self.opener.open(req)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 755, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 563, in error
result = self._call_chain(args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(args)
File "/usr/lib/python3.8/urllib/request.py", line 744, in http_error_302
raise HTTPError(req.full_url, code,
urllib.error.HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently