user10636764
user10636764

Reputation:

JSONDecodeError: Expecting value in scrapy

I am using scrapy json.load(response.body)

and we found JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Here is the link https://www.magellanprovider.com/ProviderSearchGateway/sessions/52229928/providers.jsonp?start=1&end=100&callback=jQuery112404923709263392255_1547626291787&_=1547626291795

Upvotes: 0

Views: 199

Answers (2)

ThunderMind
ThunderMind

Reputation: 799

if you haven't notice your text starts from jQuery112404923709263392255_1547626291787 due to this line, string can't be converted to json

Try using this simple regex to get the json string and then parse it to json.loads()

r'\(({.*)\);'    #it caputures anything starts from `{` and ends with `);`

Upvotes: 1

vezunchik
vezunchik

Reputation: 3717

You have JS callback in your response. Try to remove extra variables from your url like https://www.magellanprovider.com/ProviderSearchGateway/sessions/52229928/providers.jsonp?start=1&end=100 or use regex to cut json from response text.

Upvotes: 0

Related Questions