Skip to content

Instantly share code, notes, and snippets.

@categulario
Created August 16, 2012 02:03
Show Gist options
  • Save categulario/3365621 to your computer and use it in GitHub Desktop.
Save categulario/3365621 to your computer and use it in GitHub Desktop.
Juegos diversos con la API de twitter
# 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