-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTweets.py
44 lines (27 loc) · 863 Bytes
/
getTweets.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
from sys import argv
import time
from api import getAPI
RequestDelay = 5
RequestMax = 5
def main():
try:
arg1 = argv[1]
api = getAPI()
tweetResults = []
tweetindex = api.user_timeline(screen_name=arg1, count=1)[0].id
time.sleep(RequestDelay)
for requests in range(RequestMax):
tweets = api.user_timeline(screen_name=arg1, include_retweets=False,
max_id=tweetindex)
for tweet in tweets:
tweetResults.append(tweet.text)
tweetindex = tweet.id
time.sleep(RequestDelay)
print(tweetResults)
print(len(tweetResults))
except IndexError:
print("Missing Twitter Handle")
except Exception as e:
print("program failure. Error: {}".format(e))
if __name__=='__main__':
main()