Created
September 14, 2015 10:08
-
-
Save epoz/e527e9ba789f4c425b82 to your computer and use it in GitHub Desktop.
How to expand texts for a given set of ICONCLASS codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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='+'¬ation='.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='+'¬ation='.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