forked from Jefferson-Henrique/GetOldTweets-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
36 lines (27 loc) · 1.29 KB
/
Main.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
import sys
if sys.version_info[0] < 3:
import got
else:
import got3 as got
def main():
def printTweet(descr, t):
print(descr)
print("Username: %s" % t.username)
print("Retweets: %d" % t.retweets)
print("Text: %s" % t.text)
print("Mentions: %s" % t.mentions)
print("Hashtags: %s\n" % t.hashtags)
# Example 1 - Get tweets by username
tweetCriteria = got.manager.TweetCriteria().setUsername('barackobama').setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
printTweet("### Example 1 - Get tweets by username [barackobama]", tweet)
# Example 2 - Get tweets by query search
tweetCriteria = got.manager.TweetCriteria().setQuerySearch('europe refugees').setSince("2015-05-01").setUntil("2015-09-30").setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
printTweet("### Example 2 - Get tweets by query search [europe refugees]", tweet)
# Example 3 - Get tweets by username and bound dates
tweetCriteria = got.manager.TweetCriteria().setUsername("barackobama").setSince("2015-09-10").setUntil("2015-09-12").setMaxTweets(1)
tweet = got.manager.TweetManager.getTweets(tweetCriteria)[0]
printTweet("### Example 3 - Get tweets by username and bound dates [barackobama, '2015-09-10', '2015-09-12']", tweet)
if __name__ == '__main__':
main()