Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from BeautifulSoup import BeautifulSoup
- def main():
- friendsfl = open('friends.xml')
- followersfl = open('followers.xml')
- friendsoup = BeautifulSoup(friendsfl)
- followsoup = BeautifulSoup(followersfl)
- friend_list = set()
- follow_list = set()
- for friend in friendsoup('user'):
- friend_list.add(friend.contents[3].next)
- for follower in followsoup('user'):
- follow_list.add(follower.contents[3].next)
- print "Common:"
- for member in follow_list.intersection(friend_list):
- print member
- print
- print "Only follow you:"
- for member in follow_list.difference(friend_list):
- print member
- print
- print "Only you follow:"
- for member in friend_list.difference(follow_list):
- print member
- print
- print "Stats"
- print
- print "You follow, and follow you back:"
- print "%.2f" % (len(friend_list.intersection(follow_list)) / float(len(friend_list))*100),'%'
- print "Follow you, but you don't follow back:"
- print "%.2f" % ((1-len(follow_list.intersection(friend_list)) / float(len(follow_list)))*100),'%'
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment