Sunday, October 18, 2015

Retrive tweets using tweepy in Python

import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy.streaming import StreamListener
from tweepy import Stream
from tweepy.streaming import StreamListener
tweets=[]

#Variables that contains the user credentials to access Twitter API
access_token = "access token
access_token_secret = "access token secret"
consumer_key = "consumer key "
consumer_secret ="consumer secret"

auth=tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)

api=tweepy.API(auth)
public_tweets=api.home_timeline()

for tweets in public_tweets:
    print tweets.text.encode('utf-8', 'ignore')