Skip to content

Instantly share code, notes, and snippets.

@cuducos
Created January 17, 2019 11:33
Show Gist options
  • Save cuducos/3d2f4c3e6a8b500e41b00e1c2f6c1cb6 to your computer and use it in GitHub Desktop.
Save cuducos/3d2f4c3e6a8b500e41b00e1c2f6c1cb6 to your computer and use it in GitHub Desktop.
twitter-followers.py
from os import getenv
from re import sub
from tweepy import API, Cursor, OAuthHandler
from tweepy.models import User
def followers():
auth = OAuthHandler(
getenv("TWITTER_CONSUMER_KEY"), getenv("TWITTER_CONSUMER_SECRET")
)
auth.set_access_token(
getenv("TWITTER_ACCESS_TOKEN_KEY"), getenv("TWITTER_ACCESS_TOKEN_SECRET")
)
api = API(auth, wait_on_rate_limit=True)
for users in Cursor(api.followers).pages():
yield from (User.parse(api, user._json) for user in users)
def filter_users(users):
yield from (user for user in users if len(sub(r"\D", "", user.screen_name)) >= 4)
if __name__ == "__main__":
for user in filter_users(followers()):
print(user.screen_name)
@cuducos
Copy link
Author

cuducos commented Jan 17, 2019

jrmusico1986
RenatoA83677490
Andress60550538
JM10974067
1000ELAS
saro67731027
Camila19364092
lucfsantana1812
emss4891
Veronic12933821
LuizGus40573442
boyzin2000
ivansb2009
jeff0609
R25465609
Lemos2019
NormaDe94550746
Douglas375962
Leandro54409981
ClariceCC2017
Victori95723376
DanyRod20523139
caparica1975
Pedro41664776
paulor2222
MariaRa05375304
Giovann47503778
DavidSi43670477
rodrigod1987
19deh84
daniell13013006
dudis1945
LiviaMe32548551
Alessan02784386
alessan07453516
Jeh09Ma09
pereirajr1407
1c4f3t4o
matheus1975
lucassouto_1000
IMARA2013
Cleo33937795
1962camillojr
pedr0101010
Freq1915
gv084305
cyb3113
555112299jedi
15_0343
RebecaA93498695
Andre2788940267
PauloGu57110768
androra2014
Renata151617
Gudesde1988
augusto2901
fabio1079_
rafaelcb2115
biaqueiroz0311
mhjmhj2002
AngelaM71473994
henrik1950
anderson1205023
Praful21939321
coro1302
andreluiz1985
jflima2011
milo2809
esr1503
Bonny5171
Carolin96964304
ee1f88d4b7d5489
raykumar1975
BrunoSa32369355
tsds1990
c4rl0sm3nd3s
19223898
tksumanth1994
d3mian2000
COSTIS1202
Apviana2016
luizf0510
martloulou2310
Malte1986
rg3915
jefferrson2006
2486Rozy
marcosr52838475
antonio02542860
marialu03247407
RLab2012
design2000br
lacopa2011
TEA3652
radioudesc1001
MCV1289
copadesign2010
RLondrina2010
Abi1114Biguacu
rfloripa2011
asdas1234
vickyvicky1990
Arbol2009
Samuka3000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment