Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Last active December 11, 2015 21:59
Show Gist options
  • Save fmasanori/4666428 to your computer and use it in GitHub Desktop.
Save fmasanori/4666428 to your computer and use it in GitHub Desktop.
Python 3.x Twitter Client
#
# API DEPRECATED AT JUNE 2013
# https://dev.twitter.com/docs/faq#17750
#
import urllib.request
import json
def busca_tweets(texto='python'):
url = 'http://search.twitter.com/search.json?q=' + texto
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
return data['results']
def print_tweets(tweets):
for t in tweets:
print (t['from_user'] + ': ' + t['text'] + '\n')
resultados = busca_tweets('cpbr6')
print_tweets(resultados)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment