I just started using tweepy
library to connect with streaming api of twitter. I encountered both on_status()
and on_data()
methods of the StreamListener
class. What is the difference? Total noob here!
Tweepy v4. 0.0 was released recently and it merged StreamListener into Stream .
Tweepy is an open-sourced, easy-to-use Python library for accessing the Twitter API. It gives you an interface to access the API from your Python application. Alternatively, you can also install it from the GitHub repository.
Tweepy makes it easier to use the twitter streaming api by handling authentication, connection, creating and destroying the session, reading incoming messages, and partially routing messages. This page aims to help you get started using Twitter streams with Tweepy by offering a first walk through.
on_data()
handles:
whereas, on_status()
just handles statuses.
source: https://github.com/tweepy/tweepy/blob/78d2883a922fa5232e8cdfab0c272c24b8ce37c4/tweepy/streaming.py
If you're only concerned with tweets, use on_status()
. This will give you what you needed without the added information and doing so will not hinder your limit.
If you want detailed information use on_data()
. --That's rarely the case unless you're doing heavy analysis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With