pythonでふぁぼツール
本題
#!/usr/bin/env python # -*- coding:utf-8 -*- import tweepy import sys def get_oauth(): consumer_key = '' consumer_secret = '' access_key = '' access_secret = '' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) return auth def fav(screen_name, num, api): count = 0 id = 0 while count < int(num): if id == 0: tweets = api.user_timeline(screen_name) else: tweets = api.user_timeline(screen_name, max_id=id) for tweet in tweets: id = tweet.id if tweet.favorited == True: pass fav = api.create_favorite(id) count += 1 if count >= int(num): return def main(): auth = get_oauth() api = tweepy.API(auth_handler=auth) if len(sys.argv) != 3: sys.exit() else: screen_name = sys.argv[1] num = sys.argv[2] fav(screen_name, num, api) if __name__ == '__main__': main()
はい、しょぼいです。。。(泣)
まあ、適当につくったのでしょうがないですが、、、
それにしてもしょぼいです。
python favtool.py morris_555 10
こんな感じに、ふぁぼりたい相手のscreen_nameとふぁぼりたい回数を指定すればOKです。
https://gist.github.com/1554824
おわりに
今回は、こんなショボイ記事だったので拡張させてまた紹介できたらいいと思います。