Last active
October 20, 2015 03:21
-
-
Save zaltoprofen/2ffa89c182ce9cd1b0e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from configparser import ConfigParser | |
from twitter import Twitter, OAuth | |
from datetime import datetime, timezone | |
import json | |
conf = ConfigParser() | |
conf.read('config.ini') | |
oauthconf = conf['oauth'] | |
consumer_key = oauthconf['consumer_key'] | |
consumer_secret = oauthconf['consumer_secret'] | |
atoken = oauthconf['access_token'] | |
asecret = oauthconf['access_token_secret'] | |
twitter = Twitter(auth=OAuth(atoken, asecret, consumer_key, consumer_secret)) | |
if __name__ == '__main__': | |
now = datetime.now(timezone.utc) | |
inactive = [] | |
c = -1 | |
while c != 0: | |
res = twitter.friends.list(cursor=c, count=200) | |
c = res['next_cursor'] | |
for u in res['users']: | |
if 'status' not in u: | |
inactive.append({'screen_name': u['screen_name'], 'days': None}) | |
continue | |
ctime = u['status']['created_at'] | |
ct = datetime.strptime(ctime, '%a %b %d %H:%M:%S %z %Y') | |
delta = (now - ct).days | |
if delta >= 30: | |
inactive.append({'screen_name': u['screen_name'], 'days': delta}) | |
print(json.dumps(inactive)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment