Open cybergeekgyan opened 10 months ago
I am having a similar error. How should I proceed to resolve this?
I am also facing the similar error. Please suggest way to resolve this?
Iam getting this error HTTPError Traceback (most recent call last)
5 frames /usr/lib/python3.10/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs) 641 class HTTPDefaultErrorHandler(BaseHandler): 642 def http_error_default(self, req, fp, code, msg, hdrs): --> 643 raise HTTPError(req.full_url, code, msg, hdrs, fp) 644 645 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden similar to yours tell me if you have resolved
Getting same issue. Someone recommended this: https://stackoverflow.com/questions/76304936/http-error-while-accessing-the-nsetools-library-in-python
Any solutions?
Same Issue please explain why is this happening?
I'm also getting same issue , can you anyone help on this
HTTPError Traceback (most recent call last) Cell In[16], line 1 ----> 1 q = nse.get_quote('infy')
File ~\AppData\Roaming\Python\Python311\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 ~\AppData\Roaming\Python\Python311\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 ~\AppData\Roaming\Python\Python311\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:\ProgramData\anaconda3\Lib\urllib\request.py:525, in OpenerDirector.open(self, fullurl, data, timeout) 523 for processor in self.process_response.get(protocol, []): 524 meth = getattr(processor, meth_name) --> 525 response = meth(req, response) 527 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:634, in HTTPErrorProcessor.http_response(self, request, response) 631 # According to RFC 2616, "2xx" code indicates that the client's 632 # request was successfully received, understood, and accepted. 633 if not (200 <= code < 300): --> 634 response = self.parent.error( 635 'http', request, response, code, msg, hdrs) 637 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:557, in OpenerDirector.error(self, proto, args) 555 http_err = 0 556 args = (dict, proto, meth_name) + args --> 557 result = self._call_chain(args) 558 if result: 559 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, args) 494 for handler in handlers: 495 func = getattr(handler, meth_name) --> 496 result = func(args) 497 if result is not None: 498 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:749, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) 746 fp.read() 747 fp.close() --> 749 return self.parent.open(new, timeout=req.timeout)
File C:\ProgramData\anaconda3\Lib\urllib\request.py:525, in OpenerDirector.open(self, fullurl, data, timeout) 523 for processor in self.process_response.get(protocol, []): 524 meth = getattr(processor, meth_name) --> 525 response = meth(req, response) 527 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:634, in HTTPErrorProcessor.http_response(self, request, response) 631 # According to RFC 2616, "2xx" code indicates that the client's 632 # request was successfully received, understood, and accepted. 633 if not (200 <= code < 300): --> 634 response = self.parent.error( 635 'http', request, response, code, msg, hdrs) 637 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:557, in OpenerDirector.error(self, proto, args) 555 http_err = 0 556 args = (dict, proto, meth_name) + args --> 557 result = self._call_chain(args) 558 if result: 559 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, args) 494 for handler in handlers: 495 func = getattr(handler, meth_name) --> 496 result = func(args) 497 if result is not None: 498 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:749, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) 746 fp.read() 747 fp.close() --> 749 return self.parent.open(new, timeout=req.timeout)
[... skipping similar frames: OpenerDirector._call_chain at line 496 (3 times), OpenerDirector.error at line 557 (3 times), HTTPErrorProcessor.http_response at line 634 (3 times), OpenerDirector.open at line 525 (3 times), HTTPRedirectHandler.http_error_302 at line 749 (2 times)]
File C:\ProgramData\anaconda3\Lib\urllib\request.py:749, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) 746 fp.read() 747 fp.close() --> 749 return self.parent.open(new, timeout=req.timeout)
File C:\ProgramData\anaconda3\Lib\urllib\request.py:525, in OpenerDirector.open(self, fullurl, data, timeout) 523 for processor in self.process_response.get(protocol, []): 524 meth = getattr(processor, meth_name) --> 525 response = meth(req, response) 527 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:634, in HTTPErrorProcessor.http_response(self, request, response) 631 # According to RFC 2616, "2xx" code indicates that the client's 632 # request was successfully received, understood, and accepted. 633 if not (200 <= code < 300): --> 634 response = self.parent.error( 635 'http', request, response, code, msg, hdrs) 637 return response
File C:\ProgramData\anaconda3\Lib\urllib\request.py:557, in OpenerDirector.error(self, proto, args) 555 http_err = 0 556 args = (dict, proto, meth_name) + args --> 557 result = self._call_chain(args) 558 if result: 559 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, args) 494 for handler in handlers: 495 func = getattr(handler, meth_name) --> 496 result = func(args) 497 if result is not None: 498 return result
File C:\ProgramData\anaconda3\Lib\urllib\request.py:738, in HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) 735 visited = new.redirect_dict = req.redirect_dict 736 if (visited.get(newurl, 0) >= self.max_repeats or 737 len(visited) >= self.max_redirections): --> 738 raise HTTPError(req.full_url, code, 739 self.inf_msg + msg, headers, fp) 740 else: 741 visited = new.redirect_dict = req.redirect_dict = {}
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
print(q) ​
I was trying to use nsetools api to fetch indian stocks historical data, but getting this error.
Is nsetools still running or being discontinued for free usage?
🆘 need suggestions and help..