NPL, Natural Language Processing, Test Mining are some of the hot topics for research for these day. With this article I'm going to introduce how to collect tweeter data using simple code in Python.
As the first step you can install Python to your machine
- Install Python [Click Here] personally commanded 2.7 or upper
- Get Api Key [Sign in twitter]
- Install tweepy [Download tweepy from here ]
After all those steps you can download data from Tweeter. Here is the code for
import tweepy
from tweepy import Stream
from tweepy.streaming import StreamListener
ckey = '** your consumer_key **'
csecret = '** consumer secret **'
atoken = '** access token **'
asecret = '** access secret **'
class listner(StreamListener):
def on_data(self,data):
print data
return True
def on_error(self, status):
print status
auth = tweepy.OAuthHandler(ckey,csecret)
auth.set_access_token(atoken,asecret)
twitterStream = Stream(auth,listner())
twitterStream.filter(track=['car'])
when you run this code in the python shell twitter data about "car" will display on your shell
No comments:
Post a Comment