On Fri, Feb 21, 2014 at 4:05 PM, Walter Prins <wpr...@gmail.com> wrote: > > With the caveat that I'm not familiar with the Twitter streaming API's > and that I literally only spend 3 minutes googling this, it seems to > me to be the case that the Twitter streaming API's is intended to be a > push style notification service. > > This means you should not in principle ideally be polling the service > for updates yourself (e.g. using sleep/crong etc). Instead, the docs > say that the streaming API can return an iterator that yields objects > as they're decoded from the stream. Quote: > > "The TwitterStream object is an interface to the Twitter Stream API > (stream.twitter.com). This can be used pretty much the same as the > Twitter class except the result of calling a method will be an > iterator that yields objects decoded from the stream. For example::" > > It's highly preferable to not poll something if it will > generate/notify you of new objects, so you should be able to do > something like in their example. Quote: > > twitter_stream = TwitterStream(auth=UserPassAuth('joe', 'joespassword')) > iterator = twitter_stream.statuses.sample() > > for tweet in iterator: > # ...do something with this tweet... (e.g. check if you want to > retweet or something) > > So the for loop should just block by itself until a new tweet/message > comes in at which point it will spring to life and hand it to your > code to process. > > I hope that helps, and apologies if I misunderstood something or have > missed something that makes my comment irrelevant to your problem.
Hi Lists, Finally, I could monitor in real time by accessing Twitter API Stream[1]. I add the track variable to string which I'd like to monitor. Such as @mention. for tweet in twitter_stream.statuses.filter(track='example'): print tweet I use Mike Verdone's Twitter python library[2] [1]https://dev.twitter.com/docs/api/1.1/post/statuses/filter [2]https://pypi.python.org/pypi/twitter/1.13.1 Thank you all, _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor