{"id":154,"date":"2009-12-25T19:16:04","date_gmt":"2009-12-26T01:16:04","guid":{"rendered":"http:\/\/www.insomnihack.com\/?p=154"},"modified":"2009-12-25T19:16:04","modified_gmt":"2009-12-26T01:16:04","slug":"tracking-followers-with-python-twitter","status":"publish","type":"post","link":"https:\/\/www.insomnihack.com\/?p=154","title":{"rendered":"Tracking followers with python-twitter"},"content":{"rendered":"<p>There are a lot of applications out there to help manage your twitter account. Much of what these applications have to offer can be achieved with very little python code. For example, say you want to find out who is following you that you&#8217;re not following. Alternately, say you want to find out who you&#8217;re following, but who isn&#8217;t following you in return. You can find this information out easily with <a href=\"http:\/\/code.google.com\/p\/python-twitter\/\">python-twitter<\/a> and a few lines of code.<\/p>\n<p>[python]<br \/>\n#!\/usr\/bin\/env python<\/p>\n<p>import twitter<\/p>\n<p>if __name__ == &#8216;__main__&#8217;:<br \/>\n    api = twitter.Api(username=&#8217;username&#8217;, password=&#8217;password&#8217;)<br \/>\n    i_follow = api.GetFriends()<br \/>\n    follow_me = api.GetFollowers()<br \/>\n    i = [u.name for u in i_follow]<br \/>\n    f = [u.name for u in follow_me]<br \/>\n    i_should_follow = [n for n in f if n not in i]<br \/>\n    i_should_drop = [n for n in i if n not in f]<\/p>\n<p>    print &#8216;I follow:&#8217;<br \/>\n    print &#8216;\\n&#8217;.join(i)<br \/>\n    print<br \/>\n    print &#8216;Following me:&#8217;<br \/>\n    print &#8216;\\n&#8217;.join(f)<br \/>\n    print<br \/>\n    print &#8216;I should consider following:&#8217;<br \/>\n    print &#8216;\\n&#8217;.join(i_should_follow)<br \/>\n    print<br \/>\n    print &#8216;I should consider not following:&#8217;<br \/>\n    print &#8216;\\n&#8217;.join(i_should_drop)<br \/>\n    print<br \/>\n[\/python]<\/pre>\n<p>Replace the dummy user name and password and give it a go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a lot of applications out there to help manage your twitter account. Much of what these applications have to offer can be achieved with very little python code. For example, say you want to find out who is following you that you&#8217;re not following. Alternately, say you want to find out who you&#8217;re [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[6,24],"_links":{"self":[{"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/154"}],"collection":[{"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154"}],"version-history":[{"count":0,"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}