forked from tmhlsky/Instagram-API-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_followings.py
More file actions
33 lines (28 loc) · 740 Bytes
/
Copy pathuser_followings.py
File metadata and controls
33 lines (28 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Use text editor to edit the script and type in valid Instagram username/password
from InstagramAPI import InstagramAPI
import time
from datetime import datetime
user_id = ''
API = InstagramAPI("login", "password")
API.login()
API.getUsernameInfo(user_id)
API.LastJson
following = []
next_max_id = True
while next_max_id:
print next_max_id
# first iteration hack
if next_max_id is True:
next_max_id = ''
_ = API.getUserFollowings(user_id, maxid=next_max_id)
following.extend(API.LastJson.get('users', []))
next_max_id = API.LastJson.get('next_max_id', '')
len(following)
unique_following = {
f['pk']: f
for f in following
}
len(unique_following)