diff --git a/Signature.ipynb b/Signature.ipynb index 265b02cfcac49e4efc16d1471c47ec9e8b75daf2..871f36198ae4be5a599e631a19645c89f6ba63dc 100644 --- a/Signature.ipynb +++ b/Signature.ipynb @@ -2,28 +2,30 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2025-03-20T10:58:00.457437Z", "start_time": "2025-03-20T10:58:00.125731Z" } }, + "outputs": [], "source": [ "from lxml import etree\n", "import requests\n", "import pandas as pd" - ], - "outputs": [], - "execution_count": 1 + ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2025-03-20T12:29:45.828245Z", "start_time": "2025-03-20T12:29:45.824291Z" } }, + "outputs": [], "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", @@ -36,39 +38,90 @@ " 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" - ], + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "ExecuteTime": { + "end_time": "2025-03-20T12:29:45.828245Z", + "start_time": "2025-03-20T12:29:45.824291Z" + } + }, "outputs": [], - "execution_count": 21 + "source": [ + "def getSignatureAC(ac):\n", + " req= 'https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=' + ac + '&operation=searchRetrieve'\n", + " print(req)\n", + " cont=requests.get(req).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('ZHAN'), namespaces=namespaces)\n", + " return signature" + ] }, { + "cell_type": "code", + "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2025-03-20T12:29:53.843004Z", "start_time": "2025-03-20T12:29:48.334721Z" } }, - "cell_type": "code", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['2723-A']\n" + ] + } + ], "source": [ "sig = getSignature(\"136482208\")\n", "print(sig)" - ], + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['2723-A']\n" + "https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=AC14251814&operation=searchRetrieve\n" ] + }, + { + "data": { + "text/plain": [ + "['Cod. Ser. n. 14767']" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" } ], - "execution_count": 22 + "source": [ + "getSignatureAC(\"AC14251814\")" + ] }, { "cell_type": "code", + "execution_count": null, "metadata": {}, - "source": [], "outputs": [], - "execution_count": null + "source": [] } ], "metadata": { @@ -87,9 +140,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.10.16" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 }