This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: JSON Parsing Alarm: Requests + Json = JSONDecodeError
Type: crash Stage: resolved
Components: Windows Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: marikasakowa, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-04-08 17:56 by marikasakowa, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg390539 - (view) Author: Maria Kazakova (marikasakowa) Date: 2021-04-08 17:56
I tried to use the usual code:
response = requests.get (url)
response.json () OR json.loads (response.text)
BUT
it returns JSONDecodeError Expecting value: line 1 column 1 (char 0) — no matter, which website I am trying to parse, with headers or without them. 
However, response.status_code = 200 and response.text returns the whole html-content. Two days ago everything worked completely fine, and now this disaster happens. I asked a couple of friends to try the same — and everyone failed to succeed, everyone gets this error — using Jupyter Notebook (+Anaconda, Python 3.7), PyCharm (+Python 3.9) and Google Colab.
Please help :(
msg390544 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-04-08 19:34
JSON is not HTML. If response.text contains HTML, it is expected that json.loads() cannot parse it.
msg390547 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-04-08 19:58
> Two days ago everything worked completely fine, 
> and now this disaster happens.

It's unlikely that Python itself changed over those two days. It's more likely that the data source has changed.

Try this in your notebook:

    import requests
    r = requests.get('https://api.github.com/users/gvanrossum')
    print(r.status_code)
    print(r.headers['Content-Type'])
    print(r.json())

If that works, try it with your url.  If the content-type is not 'application/json; charset=utf-8', then you've identified a problem with the data source rather than with the tooling.
msg390592 - (view) Author: Maria Kazakova (marikasakowa) Date: 2021-04-09 07:08
Thank you so much for the answers!!
The problem was indeed with the data source, they have fixed it.
Sorry for bothering you! 
Wish you all the best!!!
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 87941
2021-04-09 07:08:52marikasakowasetstatus: open -> closed

nosy: - paul.moore, tim.golden, zach.ware, steve.dower
messages: + msg390592

resolution: fixed
stage: resolved
2021-04-08 19:58:43rhettingersetnosy: + rhettinger
messages: + msg390547
2021-04-08 19:34:41serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg390544
2021-04-08 17:56:34marikasakowacreate