codewithawais
codewithawais

Reputation: 579

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) (SCRAPY Shell)

I ran this URL with a scrapy shell. I tried to print the JSON response but it gave me an error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What could be the fix to it? appreciate your answers.

   scrapy shell https://directory-service-dot-gweb-edu-activity-app.appspot.com/directory/search?expertTypes=trainer&query=&userPosition=31.170406299999996,%2072.7097161
    
    >>> import json
    >>> print(json.loads(response.body))

enter image description here

Upvotes: 0

Views: 258

Answers (2)

dimay
dimay

Reputation: 2804

Try this:

import json
jd = json.dumps(response.text)
print(json.loads(jd))

Upvotes: 0

Hadrian
Hadrian

Reputation: 927

the beginning of the file looks like:

)]}',
{"partners": [],
...

which is not valid JSON. besides reporting this to the devs of the website, the only way I can figure out to fix it is to slice off the part in the beginning

print(json.loads(response.body[6:]))

Upvotes: 1

Related Questions