This code of mine works fine locally and occasionally runs with no errors here, but most of the times it throws an error saying:
Traceback (most recent call last): File "/home/AmirNsr/tweetBot/bot.py", line 266, in <module> makeNews(link) File "/home/AmirNsr/tweetBot/bot.py", line 208, in makeNews for i in data["items"]: KeyError: 'items'
Here is one the JSONs I use as an example, it definitely has the keyword 'items'
And this is the code
def makeNews(link):
r = requests.get(link)
r.text
data = json.loads(r.text)
mojaz=[]
c=0
for i in data["items"]:
if fel(data["items"][c]["title"]) and notTekrari(data["items"][c]["title"]):
mojaz.append(c)
akhbar.append(data["items"][c]["title"])
c+=1
Thanks for your help in advance