梢の金曜ロードショーは,恒例のバルス祭りということで,
バルスをツイートするpythonコードを作成しました.
twitterのAPIの制限は,15分180回ということなので,
プログラムを実行すると,その制限の限り「バルス」とつぶやき続けます.
最後の180回めには,なんとムスカが叫びます〜!
それでは,天空の城ラピュタ楽しみましょう〜!
tweetBalse.py
# coding=utf-8
import time
import tweepy
consumer_key = '****'
consumer_secret = '****'
access_key = '****'
access_secret = '****'
comment = 'バルス'
last_comment = '目が、目がぁ~〜〜〜〜〜〜〜〜!!!!!!! '
exclamation = '!'
counter = 179
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
# set access token to OAuth handler
auth.set_access_token(access_key, access_secret)
# create API
api = tweepy.API(auth_handler=auth)
for var in range(counter):
api.update_status(comment)
if len(comment) >= 140:
comment = 'バルス'
comment+=exclamation
print comment
time.sleep(0.1)
api.update_status(last_comment)
print last_comment