You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:152, in Nse.get_quote(self, code, as_json)
145 """
146 gets the quote for a given stock code
147 :param code:
148 :return: dict or None
149 :raises: HTTPError, URLError
150 """
151 code = code.upper()
--> 152 if self.is_valid_code(code):
153 url = self.build_url_for_quote(code)
154 req = Request(url, None, self.headers)
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:138, in Nse.is_valid_code(self, code)
133 """
134 :param code: a string stock code
135 :return: Boolean
136 """
137 if code:
--> 138 stock_codes = self.get_stock_codes()
139 if code.upper() in stock_codes.keys():
140 return True
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:117, in Nse.get_stock_codes(self, cached, as_json)
114 res_dict = {}
115 if cached is not True or self.CODECACHE is None:
116 # raises HTTPError and URLError
--> 117 res = self.opener.open(req)
118 if res is not None:
119 # for py3 compat covert byte file like object to
120 # string file like object
121 res = byte_adaptor(res)
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:527, in OpenerDirector.error(self, proto, *args)
525 http_err = 0
526 args = (dict, proto, meth_name) + args
--> 527 result = self._call_chain(*args)
528 if result:
529 return result
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:527, in OpenerDirector.error(self, proto, *args)
525 http_err = 0
526 args = (dict, proto, meth_name) + args
--> 527 result = self._call_chain(*args)
528 if result:
529 return result
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:533, in OpenerDirector.error(self, proto, *args)
531 if http_err:
532 args = (dict, 'default', 'http_error_default') + orig_args
--> 533 return self._call_chain(*args)
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
HTTPError Traceback (most recent call last)
Cell In[17], line 2
1 nse = Nse()
----> 2 q = nse.get_quote('infy')
3 print(q)
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:152, in Nse.get_quote(self, code, as_json)
145 """
146 gets the quote for a given stock code
147 :param code:
148 :return: dict or None
149 :raises: HTTPError, URLError
150 """
151 code = code.upper()
--> 152 if self.is_valid_code(code):
153 url = self.build_url_for_quote(code)
154 req = Request(url, None, self.headers)
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:138, in Nse.is_valid_code(self, code)
133 """
134 :param code: a string stock code
135 :return: Boolean
136 """
137 if code:
--> 138 stock_codes = self.get_stock_codes()
139 if code.upper() in stock_codes.keys():
140 return True
File e:\Scalping Tool\tradingltp\backend\venv\Lib\site-packages\nsetools\nse.py:117, in Nse.get_stock_codes(self, cached, as_json)
114 res_dict = {}
115 if cached is not True or self.CODECACHE is None:
116 # raises HTTPError and URLError
--> 117 res = self.opener.open(req)
118 if res is not None:
119 # for py3 compat covert byte file like object to
120 # string file like object
121 res = byte_adaptor(res)
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:527, in OpenerDirector.error(self, proto, *args)
525 http_err = 0
526 args = (dict, proto, meth_name) + args
--> 527 result = self._call_chain(*args)
528 if result:
529 return result
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File C:\Python313\Lib\urllib\request.py:720, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
717 fp.read()
718 fp.close()
--> 720 return self.parent.open(new, timeout=req.timeout)
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:527, in OpenerDirector.error(self, proto, *args)
525 http_err = 0
526 args = (dict, proto, meth_name) + args
--> 527 result = self._call_chain(*args)
528 if result:
529 return result
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File C:\Python313\Lib\urllib\request.py:720, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
717 fp.read()
718 fp.close()
--> 720 return self.parent.open(new, timeout=req.timeout)
File C:\Python313\Lib\urllib\request.py:495, in OpenerDirector.open(self, fullurl, data, timeout)
493 for processor in self.process_response.get(protocol, []):
494 meth = getattr(processor, meth_name)
--> 495 response = meth(req, response)
497 return response
File C:\Python313\Lib\urllib\request.py:604, in HTTPErrorProcessor.http_response(self, request, response)
601 # According to RFC 2616, "2xx" code indicates that the client's
602 # request was successfully received, understood, and accepted.
603 if not (200 <= code < 300):
--> 604 response = self.parent.error(
605 'http', request, response, code, msg, hdrs)
607 return response
File C:\Python313\Lib\urllib\request.py:533, in OpenerDirector.error(self, proto, *args)
531 if http_err:
532 args = (dict, 'default', 'http_error_default') + orig_args
--> 533 return self._call_chain(*args)
File C:\Python313\Lib\urllib\request.py:466, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
464 for handler in handlers:
465 func = getattr(handler, meth_name)
--> 466 result = func(*args)
467 if result is not None:
468 return result
File C:\Python313\Lib\urllib\request.py:613, in HTTPDefaultErrorHandler.http_error_default(self, req, fp, code, msg, hdrs)
612 def http_error_default(self, req, fp, code, msg, hdrs):
--> 613 raise HTTPError(req.full_url, code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
The text was updated successfully, but these errors were encountered: