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

We have a new json.decoder.JSONDecodeError #11

Open
javiertrek opened this issue Jun 3, 2024 · 4 comments
Open

We have a new json.decoder.JSONDecodeError #11

javiertrek opened this issue Jun 3, 2024 · 4 comments

Comments

@javiertrek
Copy link

If you try Example.py or other file.py you get this message:

Traceback (most recent call last):
File "C:\ProgramData\anaconda3\Lib\site-packages\requests\models.py", line 974, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\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\Jan\Documents\Python Scripts\ScanTrade.py", line 90, in
symbol_data = my_share.get_historical(period_type, period_value, frecuency_type, frecuency_value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Jan\Documents\Python Scripts\share.py", line 26, in get_historical
data = self._download_symbol_data(period_type, period,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Jan\Documents\Python Scripts\share.py", line 95, in _download_symbol_data
resp_json = requests.get(url, headers=headers).json()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\ProgramData\anaconda3\Lib\site-packages\requests\models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

any idea about it????

@pkout
Copy link
Owner

pkout commented Jun 3, 2024 via email

@javiertrek
Copy link
Author

I edited 95 line and changed this line:
resp_json = requests.get(url, headers=headers).json() ---- this line break code.

by these other lines:
resp_json = requests.get(url, headers=headers)
print( requests.get(url, headers=headers) )

The printed out is:

<Response [429]>

is it clear for you???

@javiertrek
Copy link
Author

I fixed it....

429 error from yahoo is for TOO MANY REQUESTS.....
I don't know why buy something change in yahoo..... but it's easy to fix it.
And I don't make too many requests.......

In share.py only change line:
headers = {'User-Agent': ''}

by this other and it works:
headers = {'User-Agent': 'your bot 0.1'}

@pkout
Copy link
Owner

pkout commented Jun 3, 2024 via email

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