]> projects.mako.cc - twitter-api-cdsw/blob - twitter4.py
b588b1c2ac4b9d259fb5f9f18c9dcd31aece78a2
[twitter-api-cdsw] / twitter4.py
1 import tweepy
2 from twitter_authentication import API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET
3
4 auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
5 auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
6
7 api = tweepy.API(auth)
8
9 # code to write the file
10 import codecs
11 output_file = codecs.open("MY_DATA.tsv", "w", "utf-8")
12
13 public_tweets = api.search("data science", count=10)
14
15 for tweet in public_tweets:
16     print >>output_file, tweet.user.screen_name + "\t" + str(tweet.created_at) + "\t" + tweet.text
17

Benjamin Mako Hill || Want to submit a patch?