1
「trump」、「clinton」というキーワードでツイートデータをクロールしたいですか?私は通常、Python3を使うのにJupiter Notebookを使います。私のコードは次のとおりです。セルを実行すると停止します。ストリーミングAPI、Pythonを使用したTwitterのマイニング
私はどちらか..
def limit_handled(cursor):
while True:
try:
yield cursor.next()
except tweepy.RateLimitError:
time.sleep(15 * 60)
以下のエラーを取得するためのコードの間にいくつかの他のコードを挿入したが動作しませんがコードです。 Jupyterノートブックを使用して
import tweepy
# OAuth setup
consumer_key = '000000000'
consumer_secret = '000000000'
access_token = '0000000000'
access_secret = '000000000'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
class MyListener(tweepy.StreamListener):
def on_data(self, data):
try:
with open('tweet_stream.json', 'a') as file:
file.write(data)
print(data)
return True
except BaseException as e:
print("Error on_data: {}".format(str(e)))
return True
twitter_stream = tweepy.Stream(auth, MyListener())
twitter_stream.filter(track=['trump', 'clinton'])
コード:
メールで送信するには、あなたの*秘密*コードはスクリーンショットです。認証キーを再生成する必要があるため、迷惑メールボットにはなりません。 –
ご意見ありがとうございます。スクリーンショットを編集してキーを再生成しました。 –