JSONDecodeError: Expecting value: line 1 column 1 Error [duplicate]
I've just started learning Python. I got this error in the code I used. I would be glad if you help. Thanks
import requests
import pandas as pd
headers = {
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-US,en;q=0.8',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Referer': 'http://www.wikipedia.org/',
'Connection': 'keep-alive',
}
response = requests.get('https://www.ebooks.com/en-tr/subjects/computers/?ResultOrder=Popularity/', headers=headers)
response.status_code
response.json() # the mistake is here
View error
Edit; I found the solution. When I used the params parameter in the requests get function, the problem was resolved and I was able to output as jason without any problems.
params = (
('subjectId', '13'),
('pageNumber', '1'),
('countryCode', 'DE'),
)
The response content is HTML, not JSON. You can view it with response.content
or response.text
.