Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (32 sloc) 0.997 kB
#!/usr/bin/env python
import sys
import time
import urllib
import urllib2
import yajl
SEARCH_URL = 'http://search.twitter.com/search.json'
def main():
if not len(sys.argv) == 2:
print 'Requires a couple of arguments'
return -1
since = time.strftime('%Y-%m-%d', time.localtime())
qs = urllib.urlencode({'q' : sys.argv[1], 'since' : since})
url_fd = urllib2.urlopen('%s?%s' % (SEARCH_URL, qs))
body = url_fd.read()
if not body:
print 'Empty body?'
return -1
data = yajl.loads(body)
if not data.get('results'):
return 0
for r in data.get('results', []):
from_user = r.get('from_user', '').lower()
if not from_user:
continue
if from_user == 'jenkinsci':
continue
retweets = r.get('metadata', {}).get('recent_retweets', 0)
print '%s : %s \n\t%s' % (from_user, retweets, r.get('text'))
return 0
if __name__ == '__main__':
sys.exit(main())
Jump to Line
Something went wrong with that request. Please try again.