Import tweepy

Tweepy is a module used to parse twitter easily and it is awesome

First your twitter application should be registered, this blog gives a step-by-step procedure for installation. .

After registering your app,try this

import tweepy

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)  #Your consumer key and secret here

auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)  #Your access key and secret here

api = tweepy.API(auth)

api.update_status('Hello tweepy')

Works like a charm!!.And remember not to give ur access or consumer keys to anyone for they may misuse it.

Now suppose you have a girlfriend called foobar and you want to stalk her profile.This will help.

page = 1

    timeline = api.user_timeline('@foobar' , count = 200,page = page)
    if timeline
        for tweet in timeline
            print tweet.text
        page = page + 1

As simple as that , you can now see the tweets foobar has posted from the time she had a twitter account.Note that max.count = 200,and increasing beyond that wouldn’t impact ,and it doesnt print retweets.



  1. Hey Manoj,

    I saw your question on Stackoverflow on “Searching and extracting top retweets using tweepy.” I am looking for similar code. Were you able to create it/find it?


    1. I haven’t till now using tweepy.What I did was extract the top 330 tweets and find the maximum number of retweets in those 330 tweets.There seems to be some limit with the number of tweets(330) to be processed.I thought something similar could be done using mechanize.Im working on it.Please tell me also if you are able to find a solution.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: