forked from jesstess/TwitterAPI
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtwitter_api.py
44 lines (38 loc) · 1.54 KB
/
twitter_api.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
43
44
import optparse
import sys
import twitter_functions
def main(args):
parser = optparse.OptionParser("""Usage: %prog [-s <search term> | -t | -u <username>]""")
parser.add_option("-s", "--search",
type="string",
action="store",
dest="search_term",
default=None,
help="Display tweets containing a particular string.")
parser.add_option("-t", "--trending-topics",
action="store_true",
dest="trending_topics",
default=False,
help="Display the trending topics.")
parser.add_option("-u", "--user-tweets",
type="string",
action="store",
dest="user_tweets",
default=False,
help="Display a user's tweets.")
parser.add_option("-w", "--trending-tweets",
action="store_true",
dest="trending_tweets",
default=False,
help="Display tweets from all of the trending topics.")
(opts, args) = parser.parse_args(args)
if opts.search_term:
twitter_functions.search(opts.search_term)
elif opts.trending_topics:
twitter_functions.trendingTopics()
elif opts.user_tweets:
twitter_functions.userTweets(opts.user_tweets)
elif opts.trending_tweets:
twitter_functions.trendingTweets()
if __name__ == "__main__":
main(sys.argv[1:])