From ece1d828d53d6123fcecb5ea8bf9b126d1728ccc Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 24 Oct 2014 12:16:51 -0400 Subject: Add code --- twitter/stream.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'twitter/stream.py') diff --git a/twitter/stream.py b/twitter/stream.py index 71cf615..4fe38c4 100644 --- a/twitter/stream.py +++ b/twitter/stream.py @@ -24,9 +24,7 @@ class Listener(StreamListener): def get_concepts(self, entities): hashtags = (hashtag["text"].lower() for hashtag in entities["hashtags"]) - users = (user["screen_name"].lower() - for user in entities["user_mentions"]) - return set(chain(hashtags, users)) + return set(hashtags) def on_status(self, tweet): concepts = self.get_concepts(tweet.entities) @@ -35,6 +33,7 @@ class Listener(StreamListener): str(tweet.user.friends_count), str(tweet.user.verified), tweet.created_at.isoformat()]) + print str(dict(tweet)) for concept in concepts: if concept in self.fhandlers: fh = self.fhandlers[concept] @@ -47,7 +46,7 @@ def process(filename, cred_file): concepts = [line.strip() for line in f] credentials = open(cred_file).readline().strip().split() os.chdir("data") - entities = [("#" + concept, "@" + concept) for concept in concepts] + entities = [("#" + concept) for concept in concepts] track = chain.from_iterable(entities) auth = OAuthHandler(*credentials[2:4]) auth.set_access_token(*credentials[4:]) -- cgit v1.2.3-70-g09d2