usr bin env python coding utf-8 import urllib import simplejson import

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import simplejson
import sys
from settings import API_KEY
url = 'http://api.semantichacker.com/%s/concept?' % API_KEY
uri = sys.argv[1]
args = {'uri': uri, 'format': 'json'}
req = urllib.urlopen(url, urllib.urlencode(args))
data = simplejson.loads(req.read())
for item in data['conceptExtractor']['conceptExtractorResponse']['concepts']:
print item['label'], item['weight']