-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_test.py
36 lines (30 loc) · 881 Bytes
/
http_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#coding: utf-8
import httplib, urllib, base64
import json
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '37d3a9eea575471a9eaaefa3fe47b1da',
}
params = urllib.urlencode({
# Request parameters
'expr': "Composite(AA.AuN=='jaime teevan')",
'model': 'latest',
'count': '10',
'offset': '0',
#'orderby': '{string}',
'attributes': 'Id,AA.AuId,F.FId,J.JId,C.CId,AA.AfId,RId',
})
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("GET", "/academic/v1.0/evaluate?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
o = json.loads(data)
#print o.keys()
entities = o["entities"]
for entity in entities:
print entity