-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
33 lines (24 loc) · 1019 Bytes
/
Copy pathprocess.py
File metadata and controls
33 lines (24 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import tweepy
#user application credentials
consumer_key="YWEorhFFtIsluvyhkBngEyxVD"
consumer_secret="sA1H4CIjYEchOdw1hVHyjWyjonpwdTi9wcNjbCpFvriZHzhjsH"
access_token="709775213-JMsM39wQImVihbdyWE0qNcdVPadaAsHyhH1KHRfF"
access_token_secret="8skFfSjx7nPNmtpQWLwxXAS7XLsct7iqavX4v0v5ZveVb"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
class CustomStreamListener(tweepy.StreamListener):
def __init__(self, api):
self.api = api
super(tweepy.StreamListener, self).__init__()
def on_status(self, status):
print status.text , "\n"
#handle errors without closing stream:
def on_error(self, status_code):
print >> sys.stderr, 'Encountered error with status code:', status_code
return True
def on_timeout(self):
print >> sys.stderr, 'Timeout...'
return True
sapi = tweepy.streaming.Stream(auth, CustomStreamListener(api))
sapi.filter(track=['dog'])