1

I'm learning about data scraping in python using tweepy and I ran on a syntax error with my code. I think I'm missing something, but it looks fine to me? Any help is appreciated. Thank you

twitterStream = Stream(auth, MyStreamListener('COVID', 'COVID-19', 'COVID19', 'NCR', 'Manila', 'Metro Manila', 'Coronavirus', 'Cases'))

twitterStream.filter(track=['COVID', 'COVID-19', 'COVID19', 'NCR', 'Manila', 'Metro Manila', 'Coronavirus', 'Cases'], async=True)

The last line of the code is where I'm getting the error.

Here's a link to view the whole code: https://paste.ofcode.org/?edit=bvg8wTJsTymfJhLgaytktD

ckdirecto
  • 41
  • 7

2 Answers2

0
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy import StreamListener


auth = OAuthHandler(config.API_KEY, config.API_SECRET)
auth.set_access_token(config.ACCESS_TOKEN, config.ACCESS_TOKEN_SECRET)
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

listener = StreamListener(api)

stream = Stream(auth, listener)

stream.filter(track=['COVID', 'COVID-19', 'COVID19', 'NCR', 'Manila', 'Metro Manila', 'Coronavirus', 'Cases'], async=True)
0

Just an FYI that in Tweepy4.0.0 StreamListner merged with Stream.

You can import it now directly via:

from tweepy import Stream

Source

Roy
  • 9
  • 1