Get number of your twitter followers in python
January 18, 2010 | frameworks, pythonauthor: Karol Zielinski | comments: 2 | views: 1559
Tags: django, followers, python, twitter
We already know how to implement functionality for automatic adding statuses to twitter. Today we will implement a functionality for automatic downloading a number of your twitter followers in python (django).
Everything via twitter API.
We will use only one method from this API, so we need to read “Twitter REST API Method: followers ids” section in this documentation. You can find this section here.
Let’s fun.
We will download amount of followers of @develway. That’s an account of a website for IT specialists and programmers.
Open *.py file (for example main/views.py) and add there a new method:
def downloadTwitterFollowers(request):
import urllib2, urllib
from django.utils import simplejson
request = urllib2.Request('http://twitter.com/followers/ids.json?screen_name=develway&cursor=-1')
response = urllib2.urlopen(request)
ids = response.read()
ids = simplejson.loads(ids)
followers = len(ids['ids'])
return HttpResponse('Amount of followers: ' + str(followers))
Now add new view to your urls.py…
Open the urls.py file and add there something like:
(r'^download-twitter-followers/$', 'ourProject.main.views.downloadTwitterFollowers'),
Save it and try to run http://yourdomain.com/download-twitter-followers/ in your web browser.
Easy, isn’t it?
Hello, I'm Karol Zielinski, internet evangelist, an entrepreneur, project manager and a web developer from Gdynia, Poland. I like creative design, good advertisement, social media and all kind of stuff around the web.
January 18, 2010, 5:04 am
[...] tech.karolzielinski.com Follow us on Twitter 5 śledzących RSS Feed 185 czytelników Pobieramy liczbę followersów w pythonie 1 głosuj! W jaki sposób zaimplementować (w pythonie/django) funkcjonalność [...]
January 27, 2010, 4:54 am
[...] we already know how to create script for getting number of followers from twitter – now it’s the best time for getting number of subscribers from feedburner. Everything [...]