Skip to content

Instantly share code, notes, and snippets.

@sauravtom
Created January 10, 2013 07:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sauravtom/4500263 to your computer and use it in GitHub Desktop.
Save sauravtom/4500263 to your computer and use it in GitHub Desktop.
Fetch tweet of a given username in command line
import urllib2
import json
def get_tweets(name):
s = urllib2.urlopen("http://search.twitter.com/search.json?q="+name).read()
x = json.loads(s)
for i in range(len(x['results'])):
print "%s.%s--> %s\n" %(i, x['results'][i]['from_user_name'], x['results'][i]['text'])
name = raw_input("Enter the twitter-username get recent tweets: ")
get_tweets(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment