From 090d82bc7b45a46f4eca24e8c8411f4a069b02fb Mon Sep 17 00:00:00 2001 From: Georg PETZ Date: Thu, 20 Mar 2025 13:44:32 +0100 Subject: [PATCH] Add method to extract signature --- Signature.ipynb | 95 +++++++++++++++++++++++++++++++++++++++++++++++ Travelogues.ipynb | 14 ------- 2 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 Signature.ipynb diff --git a/Signature.ipynb b/Signature.ipynb new file mode 100644 index 0000000..265b02c --- /dev/null +++ b/Signature.ipynb @@ -0,0 +1,95 @@ +{ + "cells": [ + { + "cell_type": "code", + "metadata": { + "ExecuteTime": { + "end_time": "2025-03-20T10:58:00.457437Z", + "start_time": "2025-03-20T10:58:00.125731Z" + } + }, + "source": [ + "from lxml import etree\n", + "import requests\n", + "import pandas as pd" + ], + "outputs": [], + "execution_count": 1 + }, + { + "cell_type": "code", + "metadata": { + "ExecuteTime": { + "end_time": "2025-03-20T12:29:45.828245Z", + "start_time": "2025-03-20T12:29:45.824291Z" + } + }, + "source": [ + "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", + " location = \"ZALT\"\n", + " xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\\'AVA\\'][marc21:subfield[@code=\\'b\\']=\\'{}\\']/marc21:subfield[@code=\\'d\\']/text()'\n", + " signature = e.xpath(xpath.format('ZALT'), namespaces=namespaces)\n", + " return signature" + ], + "outputs": [], + "execution_count": 21 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-03-20T12:29:53.843004Z", + "start_time": "2025-03-20T12:29:48.334721Z" + } + }, + "cell_type": "code", + "source": [ + "sig = getSignature(\"136482208\")\n", + "print(sig)" + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['2723-A']\n" + ] + } + ], + "execution_count": 22 + }, + { + "cell_type": "code", + "metadata": {}, + "source": [], + "outputs": [], + "execution_count": null + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.7" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Travelogues.ipynb b/Travelogues.ipynb index e169d50..9efe649 100644 --- a/Travelogues.ipynb +++ b/Travelogues.ipynb @@ -57,20 +57,6 @@ " 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", -- GitLab