diff --git a/Travelogues.ipynb b/Travelogues.ipynb index 8f82e7ee2e26e982d36622915d269c9c8a1ea57a..e169d50b353944bcb1c4f3627529d5343707fbdf 100644 --- a/Travelogues.ipynb +++ b/Travelogues.ipynb @@ -2,14 +2,14 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, "metadata": {}, - "outputs": [], "source": [ "from lxml import etree\n", "import requests\n", "import pandas as pd" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "markdown", @@ -32,9 +32,7 @@ }, { "cell_type": "code", - "execution_count": 2, "metadata": {}, - "outputs": [], "source": [ "def getMMS_ID(barcode):\n", " cont=requests.get('https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ' + barcode + '&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=dc').content\n", @@ -59,6 +57,20 @@ " place = \"; \".join(placeResult) if placeResult else ''\n", " return[year, place]\n", "\n", + "def getSignature(barcode):\n", + " cont=requests.get('https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.barcode=%2BZ' + barcode + '&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=marcxml').content\n", + " e = etree.XML(cont)\n", + " namespaces = {\n", + " 'srw': 'http://www.loc.gov/zing/srw/',\n", + " 'marc21': 'http://www.loc.gov/MARC21/slim'\n", + " }\n", + " xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\\'264\\']/marc21:subfield[@code=\\'{}\\']/text()'\n", + " yearResult = e.xpath(xpath.format('c'), namespaces=namespaces)\n", + " year = \"; \".join(yearResult) if yearResult else ''\n", + " placeResult = e.xpath(xpath.format('a'), namespaces=namespaces)\n", + " place = \"; \".join(placeResult) if placeResult else ''\n", + " return[year, place]\n", + "\n", "def getDCDataMMS(mms_id):\n", " cont=requests.get('https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.mms_id=' + mms_id + '&startRecord=0&maximumRecords=1&operation=searchRetrieve&recordSchema=dc').content\n", " e = etree.XML(cont)\n", @@ -136,167 +148,77 @@ " if not result:\n", " result = e.xpath('/rdf:RDF/bf:Instance/bf:identifiedBy/bf:Local/rdf:value/text()', namespaces=namespaces)\n", " return 'http://data.onb.ac.at/rec/' + result[0]" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Sammlung der besten Reisebeschreibungen', '', '1784']\n" - ] - }, - { - "data": { - "text/plain": [ - "['Sammlung der besten Reisebeschreibungen', '', '1784']" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "getDCDataMMS(str(990048102650603338))" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": 4, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Vorstellung der vornehmsten Völkerschaften der Welt nach ihrer Abstammung, Ausbreitung und Sprachen', 'Breitenbauch, Georg-August vonaut', '1786']\n", - "['Vorstellung der vornehmsten Völkerschaften der Welt nach ihrer Abstammung, Ausbreitung und Sprachen', 'Breitenbauch, Georg-August vonaut', '1786']\n" - ] - } - ], "source": [ "dc = getDCData(str(178966306))\n", "print(dc)" - ] + ], + "outputs": [], + "execution_count": null }, { "cell_type": "code", - "execution_count": 5, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - " | Identifier | \n", - "
---|---|
0 | \n", - "Z164418102 | \n", - "
2 | \n", - "Z97787406 | \n", - "
3 | \n", - "Z198357107 | \n", - "