Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error for Nse.get_stock_codes #146

Open
nandi691 opened this issue Aug 26, 2023 · 1 comment
Open

Getting error for Nse.get_stock_codes #146

nandi691 opened this issue Aug 26, 2023 · 1 comment

Comments

@nandi691
Copy link


AttributeError Traceback (most recent call last)
Cell In[15], line 1
----> 1 nse.get_stock_codes()

File ~/python_packages/nsetools/nse.py:110, in Nse.get_stock_codes(self, cached, as_json)
107 res_dict = {}
108 if cached is not True or self.CODECACHE is None:
109 # raises HTTPError and URLError
--> 110 res = self.opener.open(req)
111 if res is not None:
112 # for py3 compat covert byte file like object to
113 # string file like object
114 res = byte_adaptor(res)

AttributeError: 'Nse' object has no attribute 'opener'

@chalegatech
Copy link

I faced the same issue but was able to get the file working. This version of code did not have the nse_opener and nse_header methods which are there in the standard version. I copied the missing code and also some of the missing imports from the previous nse.py program. Also the req variable should have the Request output but it was within quotes. Once corrected, the code was working but the URL output did not provide the stock codes output that I was expecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants