import requests import time import json authors = [] i = True def getauthors(): start = 3965 while i: tmpauthors = [] print(start) r = requests.get(f'https://www.storytel.se/api/getSmartList.action?orderBy=LETTER&filterKeys=AUTHOR&filterValues=*&listTitle=*&start={start}&hits=50') j = json.loads(r.content) for a in j['books']: for b in a['book']['authors']: if b['name'] not in authors: print(b['name']) authors.append(b['name']) tmpauthors.append(b['name']) r.close() start = start + len(tmpauthors) if len(tmpauthors) == 0: break if len(tmpauthors) <= 15: time.sleep(312) else: time.sleep(32) for a in r['books']: for b in a['book']['authors']: print(b['name'])