25
25
# 除外ユーザ
26
26
# @ri_Zu_n_ 競馬のうるさいユーザ
27
27
# @KY1225kataware なんでやねん函館関係ないやろの人
28
- # @Miyabi207Vzs72 インスタでもうるさいr_18アカウント
28
+ # @Miyabi207Vzs72 インスタでもうるさいr_18アカウント(雅とかいうアカウント)
29
+ # @bonzu207 上の支援アカウント
29
30
# @flan_staff r_18アカウント
30
31
31
32
# 除外ボット
34
35
# rt_10 楽天トラベル
35
36
36
37
#APIキーの配列 格納の順番=> [キーワード検索用API, (あつしのAPIキー)
37
- # トップページ用API, (じょざのAPIキー)
38
+ # 知る用API, (じょざのAPIキー)
38
39
# 食べるカテゴリ用API, (じょざのAPIキー)
39
- # ニュースカテゴリ用API, (じょざのAPIキー)
40
- # 温泉カテゴリ用API, (じょざのAPIキー)
40
+ # ニュースカテゴリ用API, (じょざのAPIキー)(使ってない)
41
+ # 温泉カテゴリ用API, (じょざのAPIキー)(使ってない)
41
42
# 見るカテゴリ用API] (じょざのAPIキー)
42
43
43
44
@@ -126,7 +127,7 @@ def SaveToDatabase(tweets, tweets_data, data_label):
126
127
if tweet .source != "twittbot.net" and tweet .source != "TravelRaku" and tweet .source != "rt_10" : #ここでBOTを除外する
127
128
for i in range (len (tweets .includes ['users' ])):
128
129
if tweet .author_id == tweets .includes ['users' ][i ]['id' ]:
129
- if tweets .includes ['users' ][i ]['username' ] != "ri_Zu_n_" and tweets .includes ['users' ][i ]['username' ] != "KY1225kataware" and tweets .includes ['users' ][i ]['username' ] != "Miyabi207Vzs72" and tweets .includes ['users' ][i ]['username' ] != "flan_staff" :
130
+ if tweets .includes ['users' ][i ]['username' ] != "ri_Zu_n_" and tweets .includes ['users' ][i ]['username' ] != "KY1225kataware" and tweets .includes ['users' ][i ]['username' ] != "Miyabi207Vzs72" and tweets .includes ['users' ][i ]['username' ] != "bonzu207" and tweets . includes [ 'users' ][ i ][ 'username' ] != "flan_staff" :
130
131
ref .child (str (tweet .id )).set ({ # キーはツイートID
131
132
'data_label' : data_label ,
132
133
'date' : - (tweet .created_at .timestamp ()), #float型(確認済み)
@@ -195,8 +196,8 @@ def SearchTweets(search, tweet_max, client):
195
196
196
197
197
198
198
- # トップページ用アカウントのタイムラインの投稿をデータベースに保存する
199
- def GetTopTimeLine (tweet_max , client ):
199
+ # 知るカテゴリ用アカウントのタイムラインの投稿をデータベースに保存する
200
+ def GetKnowTimeLine (tweet_max , client ):
200
201
# 直近のツイート取得
201
202
tweets = client .get_home_timeline (
202
203
max_results = tweet_max ,
@@ -210,12 +211,12 @@ def GetTopTimeLine(tweet_max, client):
210
211
# 取得したデータ加工
211
212
tweets_data = tweets .data
212
213
213
- return SaveToDatabase (tweets , tweets_data , 'TopTimeLine ' )
214
+ return SaveToDatabase (tweets , tweets_data , 'KnowTimeLine ' )
214
215
215
216
216
217
217
- # ごはんカテゴリ用アカウントのタイムラインの投稿をデータベースに保存する
218
- def GetFoodTimeLine (tweet_max , client ):
218
+ # 食べるカテゴリ用アカウントのタイムラインの投稿をデータベースに保存する
219
+ def GetEatTimeLine (tweet_max , client ):
219
220
# 直近のツイート取得
220
221
tweets = client .get_home_timeline (
221
222
max_results = tweet_max ,
@@ -229,7 +230,7 @@ def GetFoodTimeLine(tweet_max, client):
229
230
# 取得したデータ加工
230
231
tweets_data = tweets .data
231
232
232
- return SaveToDatabase (tweets , tweets_data , 'FoodTimeLine ' )
233
+ return SaveToDatabase (tweets , tweets_data , 'EatTimeLine ' )
233
234
234
235
235
236
# 使わない
@@ -272,8 +273,8 @@ def GetFoodTimeLine(tweet_max, client):
272
273
273
274
274
275
275
- # 観光カテゴリ用アカウントのタイムラインの投稿をデータベースに保存する
276
- def GetTourTimeLine (tweet_max , client ):
276
+ # 見るカテゴリ用アカウントのタイムラインの投稿をデータベースに保存する
277
+ def GetSeeTimeLine (tweet_max , client ):
277
278
# 直近のツイート取得
278
279
tweets = client .get_home_timeline (
279
280
max_results = tweet_max ,
@@ -287,7 +288,7 @@ def GetTourTimeLine(tweet_max, client):
287
288
# 取得したデータ加工
288
289
tweets_data = tweets .data
289
290
290
- return SaveToDatabase (tweets , tweets_data , 'TourTimeLine ' )
291
+ return SaveToDatabase (tweets , tweets_data , 'SeeTimeLine ' )
291
292
292
293
293
294
@@ -309,9 +310,9 @@ def GetTourTimeLine(tweet_max, client):
309
310
# search = "函館 -is:retweet -is:reply -is:quote has:media -東京 -八王子 -札幌 -小樽 -苫小牧 OR 函館 -is:retweet -is:reply -is:quote has:links -東京 -八王子 -札幌 -小樽 -苫小牧 "
310
311
311
312
add_func = " -is:retweet -is:reply -is:quote has:media"
312
- place = " -東京 -羽田 -歌舞伎町 -八王子 -札幌 -すすきの -沖縄 -青森 -仙台 -山形 -鹿児島 -福島 -秋田 -盛岡 -神田 -土呂 -丘珠 -大宮 -新潟 -金沢 -苫小牧 -北見 -帯広 -室蘭 -夕張 -網走 -ニセコ -稚内 -留萌 -小樽 -釧路 -長万部 -旭川"
313
- r_18 = " -裏垢 -裏アカ -キャバ嬢 -パパ活 -風俗 -デブ専 -グラビアモデル"
314
- other = " -政権 -スープラ -runkeeper -戦争 -世界平和 -求人 -末広写真館 -函館に行ってきた -言霊アロマ"
313
+ place = " -東京 -原宿 - 羽田 -歌舞伎町 -八王子 -札幌 -サッポロ- すすきの -沖縄 -青森 -仙台 -山形 -沼津 -鹿児島 -福島 -秋田 -盛岡 -神田 -土呂 -丘珠 -大宮 -新潟 -金沢 -苫小牧 -北見 -帯広 -室蘭 -夕張 -網走 -ニセコ -稚内 -留萌 -小樽 -釧路 -長万部 -旭川"
314
+ r_18 = " -裏垢 -裏アカ -キャバ嬢 -パパ活 -風俗 -デブ専 -グラビアモデル -病み -夜勤 "
315
+ other = " -政権 -スープラ -runkeeper -戦争 -世界平和 -求人 -末広写真館 -函館に行ってきた -言霊アロマ -地雷 -自撮り "
315
316
# 検索対象(リツイート除外, 返信除外, 画像付きの投稿に絞る)
316
317
317
318
search = "函館" + add_func + place + r_18 + other
@@ -323,54 +324,8 @@ def GetTourTimeLine(tweet_max, client):
323
324
pprint (SearchTweets (search , tweet_max , client [0 ]))
324
325
325
326
#カテゴリごとに、アカウントのタイムラインの投稿をデータベースに保存する関数を実行
326
- pprint (GetTopTimeLine (tweet_max , client [1 ]))
327
- pprint (GetFoodTimeLine (tweet_max , client [2 ]))
327
+ pprint (GetKnowTimeLine (tweet_max , client [1 ]))
328
+ pprint (GetEatTimeLine (tweet_max , client [2 ]))
328
329
# pprint(GetNewsTimeLine(tweet_max, client[3])) #使わない
329
330
# pprint(GetSpaTimeLine(tweet_max, client[4])) #使わない
330
- pprint (GetTourTimeLine (tweet_max , client [5 ]))
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
- # テストコード
351
- # トップページ用アカウントのタイムラインの投稿をSNS_dataのキーではなく別のキーに保存する場合
352
- # Key = '格納したいキー名を書く' 今回の場合TimeLine_dataとした。何でもいいよ。
353
-
354
- # Key = 'Search'
355
- # ref = db.reference(Key)
356
- # pprint(SearchTweets(search, tweet_max))
357
-
358
- # Key = 'Top_data'
359
- # ref = db.reference(Key)
360
- # pprint(GetTopTimeLine(tweet_max))
361
-
362
- # Key = 'Food_data'
363
- # ref = db.reference(Key) #キー名のパスにアクセス
364
- # pprint(GetFoodTimeLine(tweet_max))
365
-
366
- # Key = 'News_data'
367
- # ref = db.reference(Key) #キー名のパスにアクセス
368
- # pprint(GetNewsTimeLine(tweet_max))
369
-
370
- # Key = 'Spa_data'
371
- # ref = db.reference(Key) #キー名のパスにアクセス
372
- # pprint(GetSpaTimeLine(tweet_max))
373
-
374
- # Key = 'Tour_data'
375
- # ref = db.reference(Key) #キー名のパスにアクセス
376
- # pprint(GetTourTimeLine(tweet_max))
331
+ pprint (GetSeeTimeLine (tweet_max , client [5 ]))
0 commit comments