Skip to content

Instantly share code, notes, and snippets.

@criccomini
Created January 18, 2010 04:18
Show Gist options
  • Save criccomini/279778 to your computer and use it in GitHub Desktop.
Save criccomini/279778 to your computer and use it in GitHub Desktop.
# poll a search term every 60 seconds and print tweets out
import time
import simplejson
import re
import urllib2
import urllib
last_id = False
while True:
url = 'http://search.twitter.com/search.json?q=just%20bought&rpp=100'
if last_id:
url = url + '&since_id=' + str(last_id)
search = urllib2.urlopen(url)
search = simplejson.loads(search.read())
results = search.get('results', [])
tweet_count = 0
for tweet in results:
print simplejson.dumps(tweet)
tweet_count = tweet_count + 1
last_id = search['max_id']
time.sleep(60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment