Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
simple twitter search api client
import json
import urllib
import time
def search_twitter(query, callback, maxpages=10):
resp = urllib.urlopen('' % query)
data = json.loads(
for item in data['results']:
if 'next_page' in data and maxpages > 1:
search_twitter(data['next_page'], callback, maxpages - 1)
if __name__ == '__main__':
import sys
query = '?' + urllib.urlencode({'q': ' '.join(sys.argv[1:]), 'rpp': 100})
def tester(item):
print item['text'].encode('ascii', 'replace')
search_twitter(query, tester)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.