0
以下是我的工作代碼,用於獲取某些帳戶的Twitter關注者(本例中爲@hudsonci)。Tweepy - 獲取所有關注者帳戶 - 限額問題
我的問題是,它需要吸引所有這些追隨者。這個賬戶特別有大約1000名追隨者......我一次只能達到300個限速限制。所以,這個帳戶需要大約一個小時才能獲得所有關注者。我可以想象這將成爲大型賬戶屁股的巨大痛苦。
我正在尋找一些關於如何改善這一點的建議。我覺得我沒有充分利用分頁光標,但我無法確定。
任何幫助表示讚賞。
#!/usr/bin/env python
# encoding: utf-8
import tweepy
import time
#Twitter API credentials
consumer_key = "mine"
consumer_secret = "mine"
access_key = "mine"
access_secret = "mine"
#authorize twitter, initialize tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
def handle_errors(cursor):
while True:
try:
yield cursor.next()
except tweepy.TweepError:
time.sleep(20 * 60)
for user in handle_errors(tweepy.Cursor(api.followers,screen_name='hudsonci').items()):
print user.screen_name
改劇本,包括在handle_errors '用戶(tweepy.Cursor(api.followers,SCREEN_NAME = 'hudsonci',數= 5000).items()):' 我仍然只得到300追隨者一次。計數是否在錯誤的地方?我覺得我錯過了一些非常簡單的東西。 – hansolo