clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

Download raw (801 bytes)

# Prints a list of Open Library pages (related to Anna Kavan) to index

import requests
import json
import rdflib

graph = rdflib.Graph()

ns_stats = rdflib.Namespace("")
graph.namespace_manager.bind('stats', ns_stats)

# key for Anna Kavan
author_key = 'OL200810A'
r1 = requests.get('' % author_key)

works = r1.json()

for work in works['entries']:
    r2 = requests.get('' % work['key'])

    data = r2.json()

    if data.has_key('subject_people'):
        subject = rdflib.URIRef('' % work['key'])

        for people in data['subject_people']:
            graph.add((subject, ns_stats.hasCharacter, rdflib.Literal(people)))