I’m working on a project for an exam: “social media mining”. I’m going to study the network of the channels with most follower on Twitch. nodes will be the tops channels and the link will be with them and who they follow. (not who follow those channels)
The problem is that I just can’t manage to have the list. I’m messing up with the code. The second request gives problem and the while goes on loop becouse the array “seguiti” don’t fill. In particular on that line seguiti.append(k[‘channel’][‘display_name’]).
I’m a real noob with python so maybe is a silly error but I invoke your help becouse I really can’t get out of this problem! Thank you very much.`
` off=0
n=0
top_channel = [‘Ninja’] #for tests
seguiti = []
for user in top_channel:
print(user)
follows_url = requests.get(‘https://api.twitch.tv/kraken/users/{}/follows/channels?client_id={}&offset=0&limit=100’.format(user,client_id))
follows_json= json.loads(follows_url.text)
for j in follows_json['follows']:
seguiti.append(j['channel']['display_name'])
print(len(seguiti))
print('total:')
print(follows_json['_total'])
while len(seguiti)< follows_json['_total']:
off=off+100
follows_url2 = requests.get('https://api.twitch.tv/kraken/users/{}/follows/channels?client_id={}&offset={}&limit=100'.format(user,client_id, off))
follows_json2= json.loads(follows_url2.text)
#pp.pprint(follows_json2['follows'])
for k in follows_json2['follows']:
seguiti.append(k['channel']['display_name']) #apparently it doesn't work
print(len(seguiti))
print(k['channel']['display_name'])
n=n+1
print(len(seguiti))
print(follows_json['_total'])
print(len(seguiti))
print(seguiti) ``