Python - OAI-PMH

From XennisWiki
(Redirected from Sickle)
Jump to: navigation, search

pyoai

Further information: pyoai

from oaipmh.client import Client
from oaipmh.metadata import MetadataRegistry, oai_dc_reader

registry = MetadataRegistry()
registry.registerReader('oai_dc', oai_dc_reader)
client = Client(OAI_PHM_URL, registry)

# Get record
client.getRecord(metadataPrefix='oai_dc', identifier='oai:CiteSeerX.psu:10.1.1.122.7284')

# List records
for record in client.listRecords(metadataPrefix='oai_dc'):
    header = record[0]
    print('id: {}'.format(header.identifier()))

    metadata = record[1]
    if 'creator' in metadata:
        print('creator: {}'.format(metadata['creator']))

Sickle

Further information: Sickle

client = Sickle(OAI_PHM_URL)
for record in client.ListRecords(metadataPrefix='oai_dc')
    header = record.header
    print('id: {}'.format(header.identifier))

    metadata = record.metadata
    if 'creator' in metadata:
        print('creator: {}'.format(metadata['creator']))

Use from:

client.ListRecords(**{'metadataPrefix': 'oai_dc', 'from': '2015-12-07'})