Advertisement
Guest User

Twitter diff followers

a guest
Mar 4th, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # INSTALL Tweepy library before launching the script
  5.  
  6. import tweepy
  7. import sys
  8.  
  9. USERNAME1 = "FIXME_user1"
  10. followers1 = []
  11. USERNAME2 = "FIXME_user2"
  12. followers2 = []
  13. USERNAME3 = "FIXME_user3"
  14. followers3 = []
  15.  
  16. def GetFollowers(Username, Result):
  17.     try:
  18.  
  19.         twitter_user = tweepy.api.get_user(Username)
  20.         cursor_followers = tweepy.Cursor(tweepy.api.followers, id = Username)
  21.  
  22.         print "Récupération des followers de " + Username
  23.  
  24.         compteur = 0
  25.         max_follow = twitter_user.followers_count
  26.         temp = 0
  27.         for followe in cursor_followers.items():
  28.             compteur += 1
  29.             pourcentage = (compteur * 100) / max_follow
  30.             if (pourcentage % 5 == 0) & (temp != pourcentage):
  31.                 print "\r" + str(pourcentage) + "% effectué",
  32.                 sys.stdout.flush()
  33.                 temp = pourcentage
  34.             Result.append(followe.screen_name)
  35.  
  36.     except tweepy.error.TweepError as e:
  37.         print "ERROR: " +  str(e)
  38.  
  39.  
  40. GetFollowers(USERNAME1, followers1)
  41.  
  42. GetFollowers(USERNAME2, followers2)
  43.  
  44. GetFollowers(USERNAME3, followers3)
  45.  
  46. res1 = list(set(followers1) & set(followers2))
  47. res2 = list(set(res1) & set(followers3))
  48.  
  49. for follow in res2:
  50.     print follow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement