Skip to content

Instantly share code, notes, and snippets.

@grundprinzip
Last active August 29, 2015 13:56
Show Gist options
  • Save grundprinzip/9092944 to your computer and use it in GitHub Desktop.
Save grundprinzip/9092944 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import json
import base64
import requests
import urllib
def issuccessful(request):
if 200 <= request.status_code and request.status_code <= 299:
return True
else:
return False
baseurl = "http://diufpc301:20550"
# Get the bleats
url = baseurl + "/ngrams2/" + urllib.quote_plus(sys.argv[1]) + "/ngram:cnt"
print url
request = requests.get(url, headers={"Accept" : "application/json"})
if issuccessful(request) == False:
print "Could not get messages from HBase. Text was:\n" + request.text
quit()
bleats = json.loads(request.text)
result = []
for row in bleats['Row']:
for cell in row['Cell']:
value = base64.b64decode(cell['$'])
result.append(value)
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment