Skip to content

Instantly share code, notes, and snippets.

@ettorerizza
Created January 2, 2020 06:47
Show Gist options
  • Save ettorerizza/32fb2a97ced1ff25672a0bc642dc918a to your computer and use it in GitHub Desktop.
Save ettorerizza/32fb2a97ced1ff25672a0bc642dc918a to your computer and use it in GitHub Desktop.
How to use a POST APi with Jython in OpenRefine
import urllib
import urllib2
import json
url = 'https://api.monkeylearn.com/v3/classifiers/cl_pi3C7JiL/classify/'
headers = {
'Authorization': 'Token 669523fYOUR OWN TOKEN200828427c17c28a7',
'Content-Type': 'application/json',
}
data = '{"data": ["%s"]}' % value
req = urllib2.Request(url, data, headers)
response = urllib2.urlopen(req)
result = json.loads(response.read())
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment