tweepy apiを使用してTwitterアカウントにアクセスするプロジェクトを作成しようとしていますが、ステータスコード429に直面しています。今、私は周りを見回っていますあまりにも多くのリクエスト。しかし、私は一度に10個のつぶやきしかないので、テスト中に1つしか存在しないはずです。TweepyのTwitterエラーコード429
for tweet in tweepy.Cursor(api.search, q = '@realtwitchess ',lang = ' ').items(10):
try:
text = str(tweet.text)
textparts = str.split(text) #convert tweet into string array to disect
print(text)
for x, string in enumerate(textparts):
if (x < len(textparts)-1): #prevents error that arises with an incomplete call of the twitter bot to start a game
if string == "gamestart" and textparts[x+1][:1] == "@": #find games
otheruser = api.get_user(screen_name = textparts[2][1:]) #drop the @ sign (although it might not matter)
self.games.append((tweet.user.id,otheruser.id))
elif (len(textparts[x]) == 4): #find moves
newMove = Move(tweet.user.id,string)
print newMove.getMove()
self.moves.append(newMove)
if tweet.user.id == thisBot.id: #ignore self tweets
continue
except tweepy.TweepError as e:
print(e.reason)
sleep(900)
continue
except StopIteration: #stop iteration when last tweet is reached
break
エラーが表示された場合は、最初のforループ行に表示されます。ちょっと変わった部分は、それが毎回、あるいは一定の間隔でさえも不平を言うのではないということです。時にはそれはうまくいくでしょうし、他の時間は、一見無作為に、仕事ではありません。
ループでスリープ時間を長くして項目数を減らそうとしました。