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

JSON Parsing Alarm: Requests + Json = JSONDecodeError #87941

Closed
marikasakowa mannequin opened this issue Apr 8, 2021 · 4 comments
Closed

JSON Parsing Alarm: Requests + Json = JSONDecodeError #87941

marikasakowa mannequin opened this issue Apr 8, 2021 · 4 comments
Labels
3.7 (EOL) end of life OS-windows type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@marikasakowa
Copy link
Mannequin

marikasakowa mannequin commented Apr 8, 2021

BPO 43775
Nosy @rhettinger, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-04-09.07:08:52.579>
created_at = <Date 2021-04-08.17:56:34.677>
labels = ['3.7', 'OS-windows', 'type-crash']
title = 'JSON Parsing Alarm: Requests + Json = JSONDecodeError'
updated_at = <Date 2021-04-09.07:08:52.578>
user = 'https://bugs.python.org/marikasakowa'

bugs.python.org fields:

activity = <Date 2021-04-09.07:08:52.578>
actor = 'marikasakowa'
assignee = 'none'
closed = True
closed_date = <Date 2021-04-09.07:08:52.579>
closer = 'marikasakowa'
components = ['Windows']
creation = <Date 2021-04-08.17:56:34.677>
creator = 'marikasakowa'
dependencies = []
files = []
hgrepos = []
issue_num = 43775
keywords = []
message_count = 4.0
messages = ['390539', '390544', '390547', '390592']
nosy_count = 3.0
nosy_names = ['rhettinger', 'serhiy.storchaka', 'marikasakowa']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue43775'
versions = ['Python 3.7']

@marikasakowa
Copy link
Mannequin Author

marikasakowa mannequin commented Apr 8, 2021

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 :(

@marikasakowa marikasakowa mannequin added 3.7 (EOL) end of life OS-windows type-crash A hard crash of the interpreter, possibly with a core dump labels Apr 8, 2021
@serhiy-storchaka
Copy link
Member

JSON is not HTML. If response.text contains HTML, it is expected that json.loads() cannot parse it.

@rhettinger
Copy link
Contributor

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.

@marikasakowa
Copy link
Mannequin Author

marikasakowa mannequin commented Apr 9, 2021

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!!!

@marikasakowa marikasakowa mannequin closed this as completed Apr 9, 2021
@marikasakowa marikasakowa mannequin closed this as completed Apr 9, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life OS-windows type-crash A hard crash of the interpreter, possibly with a core dump
Projects
Status: Done
Development

No branches or pull requests

2 participants