-
Notifications
You must be signed in to change notification settings - Fork 0
/
tweepy_test.py
42 lines (28 loc) · 1.42 KB
/
tweepy_test.py
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
33
34
35
36
37
38
39
40
41
42
from __future__ import absolute_import, print_function
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
# Go to http://apps.twitter.com and create an app.
# The consumer key and secret will be generated for you after
consumer_key='QhwbJVdvDhe3pm7tDJYtyx5pc'
consumer_secret='o9EgcpYJXqOckTqdhPbslZCwZrFxNMOvHHW7c636gNFRwAyeSv'
# After the step above, you will be redirected to your app's page.
# Create an access token under the the "Your access token" section
access_token='708526515777105920-WjXVWk43VCEcPGaAG77tkf4hcOaeK8h'
access_token_secret='7UACHPXOO1hgl9ykyQMzrSIobLImvUcLdRC3LWMzpfmPW'
class StdOutListener(StreamListener):
""" A listener handles tweets that are received from the stream.
This is a basic listener that just prints received tweets to stdout.
"""
def on_data(self, data):
print(data)
return True
def on_error(self, status):
print(status)
if __name__ == '__main__':
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)
stream.filter(track=['diabetes','diabetic','type1','type2','blood sugar','insulin','glucometer', 'gestational diabetes','gestation diabetes','glycemia','hypoglycemia','hyperglycemia','#diabetes','#diabetic','diet'])
#different keywords were tracked by other team members like