Search code examples
pythontweepy

Python Tweepy Search Returns absolutely nothing


I am using recommended code from tweepy. Documentation says to use:

#override tweepy.StreamListener to add logic to on_status
class MyStreamListener(tweepy.StreamListener):

    def on_status(self, status):
        print(status.text)

        myStreamListener = MyStreamListener()
        myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
        myStream.filter(track=['OWASP'])

I get an error stating that "myStreamListner" cannot be found, which is on the line of the tweepy.Stream(auth = api.auth, listener=myStreamListener)

I'm not sure why, because I have the "import tweepy" being used. Is there any additional code I need such as an extra import or do I need to add some more authorization code? I have the tokens and the keys all 4 of them added. Any advice would be nice, because the only thing I am trying to do is search for OWASP using tweepy.

I have the myStreamListener = MyStreamListener() which defines the myStreamListener which I would think is correct from tweepy's documentation.


Solution

  • I think you want to remove all indentation from those last 3 lines. They look like they should be executed at the base level.