Created
March 9, 2009 02:38
-
-
Save jcsalterego/76063 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# retrieves 10 pages of search json near:austin | |
# | |
# usage: | |
# python populate.py <search term> | |
# | |
from pprint import pprint | |
import simplejson as json | |
import urllib, urllib2 | |
import sys | |
query = 'near:austin %s' % (" ".join(sys.argv[1:])) | |
url = 'http://search.twitter.com/search.json' | |
base_params = {'geocode': '30.268735,-97.745209,25km', | |
'q': query, | |
'since_id': 0} | |
tweets = [] | |
for p in range(1, 10): | |
params = base_params | |
params['page'] = p | |
params = urllib.urlencode(params) | |
f = urllib.urlopen(url, params) | |
contents = f.read() | |
info = json.loads(contents) | |
if 'results' in info: | |
tweets += info['results'] | |
print json.dumps(tweets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment