2015-08-28 2 views
0

Je suis à la recherche d'un moyen pythonique pour obtenir un flux de tweets par hashtag. Ce que je trouve est jusqu'à présent le paquet tweepy en utilisant ce code:Python - comment obtenir des tweets en temps réel par hashtag

from tweepy import Stream 
from tweepy import OAuthHandler 
from tweepy.streaming import StreamListener 

class listener(StreamListener): 

    def on_data(self, data): 
     print(data) 
     return(True) 

    def on_error(self, status): 
     print "error" 
     print status 

auth = OAuthHandler(consumer_key, consumer_secret) 
auth.set_access_token(access_token, access_secret) 

twitterStream = Stream(auth, listener()) 
twitterStream.filter(track=["#iPhone"]) 

Le problème est que je ne comprends pas comment puis-je obtenir les consumer_key, consumer_secret, access_token, access_secret arguments.

Je fais la bonne chose? Est-ce la meilleure façon de collecter des tweets par un hashtag en utilisant python? Si oui, comment obtenir les 4 arguments?

+0

[RTFM] (http://tweepy.readthedocs.org/en/v3.2.0/auth_tutorial.html#auth-tutorial)! – jonrsharpe

+0

merci mec, il suffit de prendre les choses ;-) – farhawa

+1

Ha! mais pour de vrai – FirebladeDan

Répondre