Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. from BeautifulSoup import BeautifulSoup
  2.  
  3. def main():
  4. friendsfl = open('friends.xml')
  5. followersfl = open('followers.xml')
  6. friendsoup = BeautifulSoup(friendsfl)
  7. followsoup = BeautifulSoup(followersfl)
  8.  
  9. friend_list = set()
  10. follow_list = set()
  11.  
  12. for friend in friendsoup('user'):
  13. friend_list.add(friend.contents[3].next)
  14. for follower in followsoup('user'):
  15. follow_list.add(follower.contents[3].next)
  16.  
  17. print "Common:"
  18. for member in follow_list.intersection(friend_list):
  19. print member
  20.  
  21. print
  22. print "Only follow you:"
  23. for member in follow_list.difference(friend_list):
  24. print member
  25.  
  26. print
  27. print "Only you follow:"
  28. for member in friend_list.difference(follow_list):
  29. print member
  30.  
  31. print
  32. print "Stats"
  33. print
  34. print "You follow, and follow you back:"
  35. print "%.2f" % (len(friend_list.intersection(follow_list)) / float(len(friend_list))*100),'%'
  36.  
  37. print "Follow you, but you don't follow back:"
  38. print "%.2f" % ((1-len(follow_list.intersection(friend_list)) / float(len(follow_list)))*100),'%'
  39.  
  40. if __name__ == '__main__':
  41. main()
Add Comment
Please, Sign In to add comment