以下のコードは、過去6ヶ月間、一部のTwitterアカウントのフォロワーを取得するために完全に機能しました。突然、今朝、コードは「Error 401:Unauthorized」を返して動作を停止しました。Twitter API用のPython Tweepyが「エラー401:未承認」を返します
dev.twitter.comで自分のアプリケーションをチェックしましたが、それでも有効です。私はTweepyを更新しました。なぜこれがもう働かないのか分かりません。
コードは 'Cursor.next'行で失敗します。
import tweepy
import mysql.connector
import time
consumer_key = 'secretkey'
consumer_secret = 'secretsecret'
access_token = 'secrettoken'
access_token_secret = 'secrettokensecret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
for twit_name in twit_name_array:
api = tweepy.API(auth)
t0= time.clock()
data = api.rate_limit_status()
user_followers_remaining = data['resources']['followers']['/followers/ids']['remaining']
print(user_followers_remaining)
id_i = twit_name[1]
countpage = 0
countx = 0
def limit_handled(cursor):
while True:
data = api.rate_limit_status()
user_followers_remaining = data['resources']['followers']['/followers/ids']['remaining']
if user_followers_remaining>0:
try:
yield cursor.next()
except BaseException as e:
print('failed_on_CURSOR_NEXT', str(e))
global api
api = tweepy.API(auth)
try:
yield cursor.next()
except BaseException as e:
print('failed_on_CURSOR_NEXT_2', str(e))
break
else:
for min_remain in range(-3, 0):
print('##### TIMEOUT ##### ----- Out of queries, waiting ' + str(min_remain*5) + 'min')
time.sleep(5*60)
おそらく、OAuthログインをもう一度やり直す必要がありますか? – advance512
私はそれを試みた。私もいくつかの他のクエリ(tweet_get)または(タイムライン)を試しましたが、それらのどれももうこれ以上働いていません... – ylnor
この問題のアップデートはありますか?私はいつか今でも同様の問題を解決しようとしています –