Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active June 20, 2016 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/b4d219047f8accbfa60aaa166eface47 to your computer and use it in GitHub Desktop.
Save kurozumi/b4d219047f8accbfa60aaa166eface47 to your computer and use it in GitHub Desktop.
【Python】tweepyを使ってフォロワーを一括でフォローする方法
# codin: utf-8
import tweepy
def oauth():
consumer_key = "consumer_key"
consumer_secret = "consumer_secret"
access_key = "access_key"
access_secret = "access_secret"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
return auth
# API制限にひっかかったら15分待機するジェネレーター
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweet.RateLimitError:
time.sleep(15 * 60)
if __name__ == "__main__":
api = tweepy.API(oauth())
if follower in limit_handled(tweepy.Cursor(api,followers).items()):
if follower.friends_count < 300:
follower.follow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment