问题
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!
回答1:
on_data()
handles:
- replies to statuses
- deletes
- events
- direct messages
- friends
- limits, disconnects and warnings
whereas, on_status()
just handles statuses.
source: https://github.com/tweepy/tweepy/blob/78d2883a922fa5232e8cdfab0c272c24b8ce37c4/tweepy/streaming.py
回答2:
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.
来源:https://stackoverflow.com/questions/31054656/what-is-the-difference-between-on-data-and-on-status-in-the-tweepy-library