forked from zwmccall/Python_Projects-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.py
36 lines (30 loc) · 943 Bytes
/
twitter.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
'''
retrieves tweets from home
ofcourse! We will specify the limit
'''
import tweepy
from tweepy import OAuthHandler
# Here be main
def main():
# variables for keys
consumerKey = input('Enter your consumer key: ')
consumerSecret = input('Enter your consumer secret: ')
accessToken = input('Enter your access token: ')
accessSecret = input('Enter your access secret: ')
# OPEN HANDLE TO FILE
#we will have all the tweets stored here
handle=open('tweets.txt','w')
# Auth variables
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
auth.set_access_token(accessToken, accessSecret)
api = tweepy.API(auth)
# <Insert cool stuff here>
for status in tweepy.Cursor(api.home_timeline).items(100):
# Process a single status
print (status.text)
#utf-8 encoding for readability
handle.write(status.text.encode('utf-8'))
handle.write('\n \n')
handle.close()
# Here be main starting its game
if __name__ == "__main__": main()