Created
August 16, 2012 02:03
-
-
Save categulario/3365621 to your computer and use it in GitHub Desktop.
Juegos diversos con la API de twitter
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
# http://search.twitter.com/search.json?q=query | |
#Juegos diversos con twitter | |
from urllib import urlopen | |
import json | |
from pprint import pprint | |
def busca_tweets(cadena): | |
result = urlopen("http://search.twitter.com/search.json?q=" + cadena) | |
tweets = json.loads(result.read()) | |
for tweet in tweets['results']: | |
if cadena in tweet['text']: | |
print ">>", tweet['text'] | |
#"http://twitter.com/statuses/user_timeline.json?screen_name="+username | |
def busca_usuario(usuario): | |
result = urlopen("http://twitter.com/statuses/user_timeline.json?screen_name=" + usuario) | |
tweets = json.loads(result.read()) | |
for tweet in tweets: | |
print '>>', tweet['text'] | |
texto = tweet['text'].split(' ') | |
for i in texto: | |
if i.startswith('@'): | |
print i | |
else: | |
return | |
print "Un error" | |
if __name__ == "__main__": | |
#busca_tweets(raw_input("Que quieres buscar en twitter? ")) | |
busca_usuario(raw_input("Que usuario quieres buscar en twitter? ")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment