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

index_pe_pb_div results in JSONDecodeError #30

Closed
devfinwiz opened this issue Oct 2, 2023 · 4 comments
Closed

index_pe_pb_div results in JSONDecodeError #30

devfinwiz opened this issue Oct 2, 2023 · 4 comments

Comments

@devfinwiz
Copy link

from nsepython import index_pe_pb_div

def dataset_generator():  
    symbol = "NIFTY 50"
    start_date = "01-Mar-2011"
    end_date = "07-Jun-2021"
    print(index_pe_pb_div(symbol,start_date,end_date))
    
dataset_generator()
Traceback (most recent call last):
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Dev.Juneja\Downloads\Fin-Maestro\Prerequisites\test.py", line 9, in <module>
    dataset_generator()
  File "c:\Users\Dev.Juneja\Downloads\Fin-Maestro\Prerequisites\test.py", line 7, in dataset_generator
    print(index_pe_pb_div(symbol,start_date,end_date))
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nsepython\rahu.py", line 727, in index_pe_pb_div
    payload = requests.post('https://niftyindices.com/Backpage.aspx/getpepbHistoricaldataDBtoString', headers=niftyindices_headers,  data=data).json()
  File "C:\Users\Dev.Juneja\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@devfinwiz
Copy link
Author

Not receiving this exception anymore but getting an empty dataframe as result for few indices. Eg: Nifty Smallcap 100.

vidishraj added a commit to vidishraj/nsepython that referenced this issue Oct 18, 2023
Resolved 401 code error. 
Related to issue: index_pe_pb_div results in JSONDecodeError aeron7#30
Added cookies to header that are fetched from the main domain
vidishraj added a commit to vidishraj/nsepython that referenced this issue Oct 18, 2023
Resolved 401 code error. 
Related to issue: index_pe_pb_div results in JSONDecodeError aeron7#30
Added cookies to header that are fetched from the main domain
@aeron7
Copy link
Owner

aeron7 commented Nov 28, 2023

@aeron7 aeron7 closed this as completed Nov 28, 2023
@devfinwiz
Copy link
Author

devfinwiz commented Nov 28, 2023

Mind checking the above url once @aeron7 ? I feel there is some problem with it...

@dsanr
Copy link

dsanr commented Sep 8, 2024

@aeron7 I am getting an empty dataframe for 'nifty largemidcap 250' and 'nifty smallcap 100' indices, using index_pe_pb_div method.

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

3 participants