I use the search streams API for League of Legends (just an example) and store the page.
Using Python, I iterate of each of the streams via a for loop:
def grab_viewership_information(self,data):
#compile data for current url
try:
for stream in data["streams"]:
if stream["game"] == self.name:
self.dictionary_of_viewers[stream["channel"]["display_name"]] = stream["viewers"]
else:
pass
return self.dictionary_of_viewers
except KeyError:
print("STREAM ERRORRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")
return self.dictionary_of_viewers
I was initially not error handling and would recieve KeyErrors randomly, but frequently enough to have to do this.
Does anyone know why KeyErrors would return?