我一直在尝试捕获用户关注其他用户的时间 在推特,但我卡住了。这就是我现在所拥有的。
import tweepy
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
#Twitter API credentials
consumer_key = '...'
consumer_secret = '...'
access_token = '...'
access_secret = '...'
class StdOutListener(tweepy.StreamListener):
def on_event(self, event):
if event.event == 'follow':
time = event.created_at
print(time)
source_user = event.source
target_user = target_user
some_process(time, source_user, target_user)
if __name__ == '__main__':
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
stream = tweepy.Stream(auth, l)
stream.sitestream(follow=['31415926','5358979'])