Advertisement
fmasanori

Simple Python 3.x Twitter Client

Sep 30th, 2011
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #Python 3.x, for Python 2.7 Twitter Client: http://pastebin.com/peP6nrhf
  2. import urllib.request
  3. import json
  4.  
  5. def busca_tweets(texto='python'):
  6.   url = 'http://search.twitter.com/search.json?q=' + texto
  7.   resp = urllib.request.urlopen(url).read()
  8.   data = json.loads(resp.decode('utf-8'))
  9.   return data['results']
  10.  
  11.  
  12. def print_tweets(tweets):
  13.   for t in tweets:
  14.     print (t['from_user'] + ': ' + t['text'] + '\n')
  15.  
  16. resultados = busca_tweets('TDC2012')
  17. print_tweets(resultados)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement