-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwintTreeSearch.py
58 lines (43 loc) · 1.47 KB
/
TwintTreeSearch.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 twint.output
from TreeUser import *
import twint.user
def retconfig(username):
c = twint.Config
c.Username = username
c.Hide_output = True
c.Store_object = True
c.User_full = True
return c
def getsingleuser(username):
c = retconfig(username)
twint.run.Lookup(c)
return TreeUser(twint.output.users_list[0])
def searchfollowers(user):
c = retconfig(user.username)
twint.output.users_list.clear()
twint.run.Followers(c)
for userout in twint.output.users_list:
user.followerslist.add(userout.username)
return [TreeUser(tuser) for tuser in twint.output.users_list]
def searchfollowing(user):
c = retconfig(user.username)
twint.output.follows_list.clear()
twint.run.Following(c)
for userout in twint.output.users_list:
user.followinglist.add(userout.username)
return [TreeUser(tuser) for tuser in twint.output.users_list]
def searchtweets(user):
c = retconfig(user.username)
twint.output.tweets_list.clear()
twint.run.Search(c)
hashtags = dict()
for hashtag in [tags for tweet in twint.output.tweets_list for tags in tweet.hashtags]: # combine all hashtags from tweets
if hashtag in user.tweetedhashtags.keys():
hashtags += 1
else:
hashtags[hashtag] = 1
return twint.output.tweets_list, hashtags
def searchfavourites(user):
twint.output.tweets_list.clear()
c = retconfig(user.username)
return twint.output.tweets_list