File tree 2 files changed +38
-2
lines changed
2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -524,8 +524,16 @@ def getPopularFeed(self):
524
524
return popularFeed
525
525
526
526
def getUserFollowings (self , usernameId , maxid = '' ):
527
- return self .SendRequest ('friendships/' + str (usernameId ) + '/following/?max_id=' + str (maxid )
528
- + '&ig_sig_key_version=' + self .SIG_KEY_VERSION + '&rank_token=' + self .rank_token )
527
+ url = 'friendships/' + str (usernameId ) + '/following/?'
528
+ query_string = {
529
+ 'ig_sig_key_version' : self .SIG_KEY_VERSION ,
530
+ 'rank_token' : self .rank_token ,
531
+ }
532
+ if maxid :
533
+ query_string ['max_id' ] = maxid
534
+ url += urllib .urlencode (query_string )
535
+
536
+ return self .SendRequest (url )
529
537
530
538
def getSelfUsersFollowing (self ):
531
539
return self .getUserFollowings (self .username_id )
Original file line number Diff line number Diff line change
1
+ from InstagramAPI import InstagramAPI
2
+ import time
3
+ from datetime import datetime
4
+
5
+ username = ''
6
+ pwd = ''
7
+ user_id = '19343908'
8
+
9
+
10
+ API = InstagramAPI (username ,pwd )
11
+ API .login ()
12
+
13
+ following = []
14
+ next_max_id = True
15
+ while next_max_id :
16
+ print next_max_id
17
+ #first iteration hack
18
+ if next_max_id == True : next_max_id = ''
19
+ _ = API .getUserFollowings (user_id ,maxid = next_max_id )
20
+ following .extend ( API .LastJson .get ('users' ,[]))
21
+ next_max_id = API .LastJson .get ('next_max_id' ,'' )
22
+
23
+ len (following )
24
+ unique_following = {
25
+ f ['pk' ] : f
26
+ for f in following
27
+ }
28
+ len (unique_following )
You can’t perform that action at this time.
0 commit comments