2020年12月19日星期六

How to stream tweets from private accounts using Tweepy

I have been having problems with the MyStreamListener from tweepy, in where I am unable to fetch tweets from private accounts I follow. I know these tweets can be accessed with the API, because I can fetch them with api.user_timeline. Is there any way to be able to stream my whole timeline? Could I just continuously fetch my timeline in a while loop? Thank you for any help!

import tweepy    consumer_key = ''  consumer_secret = ''  access_token = ''  access_token_secret = ''  webhooklink = ''    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)  auth.set_access_token(access_token, access_token_secret)  api = tweepy.API(auth)  print('starting to monitor!')      class MyStreamListener(tweepy.StreamListener):      def on_status(self, status):          print(status.text)    if __name__ == '__main__':      myStreamListener = MyStreamListener()      myStream = tweepy.Stream(auth=api.auth, listener=myStreamListener)      myStream.filter(          follow='25073877', is_async=True)  


from Recent Questions - Stack Overflow https://stackoverflow.com/questions/65376932/how-to-stream-tweets-from-private-accounts-using-tweepy MaxP

没有评论:

发表评论