-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_script.py
37 lines (29 loc) · 947 Bytes
/
twitter_script.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
"""
twitter_script is fetching all tweets for a twitter user
"""
import tweepy
from tweepy import Stream, OAuthHandler
from tweepy.streaming import StreamListener
#API key
consumer_key=""
#API secret key
consumer_secret=""
access_token=""
access_token_secret=""
class StdOutListener(StreamListener):
def on_data(self, data):
print(data)
return True
def on_error(self, status):
print(status)
auth = OAuthHandler(consumer_key , consumer_secret)
auth.set_access_token(access_token , access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True,
wait_on_rate_limit_notify=True, retry_count=3, retry_delay=60)
twitterstream = Stream(auth, StdOutListener())
#tweets = twitterstream.filter(track=["car"])
#print(tweets)
# user = api.get_user(901277118654500869)
# print(user.screen_name)
alltweets = api.user_timeline(screen_name = "ehabfeki",count=10)
print(alltweets)