Skip to content

Instantly share code, notes, and snippets.

@epoz
Created September 14, 2015 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epoz/e527e9ba789f4c425b82 to your computer and use it in GitHub Desktop.
Save epoz/e527e9ba789f4c425b82 to your computer and use it in GitHub Desktop.
How to expand texts for a given set of ICONCLASS codes
codes = ['31D11222', '34B11', '45(+26)', '45C1', '45D12', '48C7341']
codes = [urllib.quote(x) for x in codes]
paths = set()
for obj in json.loads(urllib2.urlopen('http://iconclass.org/json/?notation='+'&notation='.join(codes)).read()):
paths.update(obj.get('p'))
paths.add(obj.get('n'))
txts = []
kws = set()
for p in json.loads(urllib2.urlopen('http://iconclass.org/json/?notation='+'&notation='.join(paths)).read()):
txts.append(p.get('txt').get('de', u''))
for k in p.get('kw').get('de', []):
kws.add(k)
txts.extend(sorted(kws))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment