-
-
Save Zulko/f8735acf94cc97d6c53d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Rewrite with Twittcher ;) | |
Result (every 20 seconds): | |
>>> Most common words: [('ferguson', 41), ('http', 28), ('protests', 9), | |
('missouri', 9), ('leave', 8), ('continue', 8),...] | |
''' | |
import re | |
from collections import Counter | |
from twittcher import SearchWatcher | |
counter = Counter() | |
def action(tweet): | |
words = [w for w in re.findall("\w+",tweet.text) if len(w)>3] | |
counter.update([w.lower() for w in words]) | |
print ("Most common words: %s"%(counter.most_common(20))) | |
bot = SearchWatcher("ferguson", action=action) | |
bot.watch_every(20) # 20 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment