-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (29 loc) · 1.12 KB
/
main.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
from tweepy import StreamListener
from tweepy import Stream
import tweepy
import json
import TwitterListener
import threading
consumer_key = '5z0sfk6FYOa6HQwsW50o2rcTc'
consumer_secret = 'uSf6mPLhqVew9QyWsFUp8N6cUEpBDRNwrU48hRpsMrJzOId7UK'
access_token_key = '912715351355383808-ExBFy5wIibRYYuKnjGRarHtzNxXPPnG'
access_token_secret = 'p4VlHmYZwSSUNakbUVz4xU0qrqdX8Vo2EkWXMMu7jkmfR'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
if __name__ == '__main__':
twitter_name_id_file = open('twitter_name_id')
id_list = []
# allowed twitter name
twitter_name = set()
# adding twitter list
for x in twitter_name_id_file.readlines():
twitter, id = x.split()
twitter_name.add(twitter.lower())
id_list.append(id)
print(len(twitter_name))
twitterListener = TwitterListener.TwitterListener(twitter_name)
twitterStream1 = Stream(auth, twitterListener)
twitterStream2 = Stream(auth, twitterListener)
print('connecting..')
twitterStream1.filter(follow=id_list[:len(id_list)], async=True)
print('listening..')