-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.py
37 lines (25 loc) · 1012 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
37
import tweepy
import json
import csv
import time
consumer_key = "MNIWwfj1BMpL5XrDYb4YotrFK"
consumer_secret = "ZSK0fCeT78TG6zptHbR8JrsnOAB8BKWGBB0q8jx1ldYzYfCYnm"
access_token = "132813210-Wu6aCnnxOPvbotu2kCXu33W1I2DMHVRrFN0Y4zPV"
access_token_secret = "FOqGMGPs5DXJkWkFqTZavSZ1Li5vD7jusQsp7gcV0PIKR"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api=tweepy.API(auth)
csvFile=open('kabali.csv','w')
csvWriter=csv.writer(csvFile)
c = tweepy.Cursor(api.search, q="Kabali",lang="en").items(1000)
while True:
try:
tweet=c.next()
print "Text :" + tweet.text + " Created at : " + str(tweet.created_at) + "\n"
csvWriter.writerow([tweet.text.encode('utf-8')])
except tweepy.TweepError:
time.sleep(2)
continue
except StopIteration:
break
csvFile.close()