I'm trying to use the Raspberry Pi to get data from a json file. It works fine if i run the script on my pc, but at the Raspberry i get these Errors:
Code:
import requests
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.5",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"DNT": "1",
"Host": "api.sofascore.com",
"Origin": "https://www.sofascore.com",
"Pragma": "no-cache",
"Referer": "https://www.sofascore.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"Sec-GPC": "1",
"TE": "trailers",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
}
url = "https://api.sofascore.com/api/v1/sport/football/scheduled-events/2023-05-29"
response = requests.get(url,headers=headers).json()
Errors:
Traceback (most recent call last):
File "<string>", line 25, in <module>
File "/usr/lib/python3/dist-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
With other json files it works. I have tried a few things, the error means that the response is empty(?), but when I say 'print(response.text)' the (I think) encrypted text is printed. Is there another way to decrypt this or does anyone know why it doesn't work with that file on the Raspberry? Or do i miss something at the Header?
Thanks for your help