-
Notifications
You must be signed in to change notification settings - Fork 0
/
twee.py
58 lines (45 loc) · 1.41 KB
/
twee.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import tweepy as tw
#keys are stored in a local file keys.py
from keys import *
# Authorizing the Application to your account
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tw.API(auth)
# Your Home Timeline:
def home():
print('Home Timeline:')
for tweet in tw.Cursor(api.home_timeline).items(10):
print(tweet.text)
def search(q):
for tweet in tw.Cursor(api.search, q=q).items(5):
print(tweet.text)
# Retweet
def retweet(id):
api.retweet(id=id)
print('Tweet retweeted!')
# Tweet
def update(status):
api.update_status(status)
print('Your tweet has been posted!')
# Delete your last tweet
def delete():
tweet = api.user_timeline()[0]
api.destroy_status(tweet.id)
print('Your last tweet: "' + tweet.text + '" has been deleted')
# Mentions
def mentions():
print('Your mentions:')
for mention in tw.Cursor(api.mentions_timeline).items():
print(mention.text)
# People you follow:
def following():
print('You follow:')
# If you have a long following list, add num of followers you want to access as param to items()
for friend in tw.Cursor(api.friends).items():
print(friend.name)
# Your followers:
def followers():
print('People following you:')
for follower in tw.Cursor(api.followers).items():
print(follower.name)
#Put function calls here to get your results