Я пытаюсь добавить все данные для каждого результата в l oop в один json файл.
Вот мой код:
for obj in all_psts: # There About 245 objs
for i in range(1, 500):
s = requests.Session()
s.proxies = <my_proxy>
resp = s.get("https://api/ur/{0}/recipients?page={1}".format(obj, i),
headers=header, verify=False).json()
if resp: # If the page is not empty
a = []
a.extend(a)
with open(pst_rec_path, 'w', encoding='utf-8', errors='ignore') as file:
json.dump(a, file, ensure_ascii=False, indent=1, sort_keys=False, default=str)
elif not resp: #if there is no data, stop the statement and run the next obj
print('should stop and go to next obj')
continue
Однако я сохраняю получаю это сообщение об ошибке:
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Есть идеи или предложения относительно того, почему я продолжаю получать эту ошибку?