17
17
consumer_secret = 'YOUR_APP_SECRET'
18
18
access_token = 'YOUR_ACCESS_TOKEN'
19
19
access_token_secret = 'YOUR_TOKEN_SECRET'
20
+
20
21
twitter = Twython (consumer_key , consumer_secret , oauth_version = 1 )
21
22
22
23
auth = tweepy .OAuthHandler (consumer_key , consumer_secret )
@@ -53,6 +54,8 @@ def defineOptions():
53
54
users [a ['screen_name' ]] = {}
54
55
users [a ['screen_name' ]]['hashtags' ] = []
55
56
57
+ for hashtag in tweet ._json ['entities' ]['hashtags' ]:
58
+ users [a ['screen_name' ]]['hashtags' ].append (hashtag ['text' ])
56
59
57
60
58
61
for u in users .keys ():
@@ -69,15 +72,22 @@ def defineOptions():
69
72
elif g == "undetermined" : undefined_c += 1
70
73
71
74
total_count = len (users )
72
-
75
+ users ['total_count' ] = total_count
76
+ users ['female_count' ] = female_c
77
+ users ['male_count' ] = male_c
78
+ users ['nonbinary_count' ] = nonbinary_c
79
+ users ['undefined_count' ] = undefined_c
73
80
74
81
if len (users ) > 0 :
75
82
female_rate = str ((female_c * 100 ) / total_count )+ "%"
76
83
male_rate = str ((male_c * 100 ) / total_count )+ "%"
77
84
nonbinary_rate = str ((nonbinary_c * 100 ) / total_count )+ "%"
78
85
undefined_rate = str ((undefined_c * 100 ) / total_count )+ "%"
79
86
80
-
87
+ users ['female_rate' ] = female_rate
88
+ users ['male_rate' ] = male_rate
89
+ users ['nonbinary_rate' ] = nonbinary_rate
90
+ users ['undefined_rate' ] = undefined_rate
81
91
82
92
83
93
f = open ( '../out/' + args .screen_name + '_tweets.json' , 'w' )
0 commit comments