Last active
December 11, 2015 21:59
-
-
Save fmasanori/4666747 to your computer and use it in GitHub Desktop.
Python 3.x Twitter Followers
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
# | |
# API DEPRECATED AT JUNE 2013 | |
# https://dev.twitter.com/docs/faq#17750 | |
# | |
import urllib.request | |
import json | |
url = 'http://api.twitter.com/1/followers/ids.json?screen_name=fmasanori' | |
resp = urllib.request.urlopen(url).read() | |
flws = json.loads(resp.decode('utf-8')) | |
#sem autenticação o limite por hora são 150 acessos | |
#nesta oficina vamos mostrar os 42 primeiros | |
cont = 0 | |
for fid in flws['ids']: | |
url = 'http://api.twitter.com/1/users/lookup.json?user_id=%s' %fid | |
resp = urllib.request.urlopen(url).read() | |
flw = json.loads(resp.decode('utf-8')) | |
flw = flw[0] | |
print (flw['screen_name'], flw['followers_count']) | |
cont += 1 | |
if cont == 42: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment