Skip to content
Snippets Groups Projects
Commit 9fe81183 authored by Georg Petz's avatar Georg Petz
Browse files

Add method to extract signature with AC

parent 090d82bc
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from lxml import etree from lxml import etree
import requests import requests
import pandas as pd import pandas as pd
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def getSignature(barcode): def getSignature(barcode):
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 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
e = etree.XML(cont) e = etree.XML(cont)
namespaces = { namespaces = {
'srw': 'http://www.loc.gov/zing/srw/', 'srw': 'http://www.loc.gov/zing/srw/',
'marc21': 'http://www.loc.gov/MARC21/slim' 'marc21': 'http://www.loc.gov/MARC21/slim'
} }
location = "ZALT" location = "ZALT"
xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\'AVA\'][marc21:subfield[@code=\'b\']=\'{}\']/marc21:subfield[@code=\'d\']/text()' xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\'AVA\'][marc21:subfield[@code=\'b\']=\'{}\']/marc21:subfield[@code=\'d\']/text()'
signature = e.xpath(xpath.format('ZALT'), namespaces=namespaces) signature = e.xpath(xpath.format('ZALT'), namespaces=namespaces)
return signature return signature
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def getSignatureAC(ac):
req= 'https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=' + ac + '&operation=searchRetrieve'
print(req)
cont=requests.get(req).content
e = etree.XML(cont)
namespaces = {
'srw': 'http://www.loc.gov/zing/srw/',
'marc21': 'http://www.loc.gov/MARC21/slim'
}
location = "ZALT"
xpath = '/srw:searchRetrieveResponse/srw:records/srw:record/srw:recordData/marc21:record/marc21:datafield[@tag=\'AVA\'][marc21:subfield[@code=\'b\']=\'{}\']/marc21:subfield[@code=\'d\']/text()'
signature = e.xpath(xpath.format('ZHAN'), namespaces=namespaces)
return signature
```
%% Cell type:code id: tags:
``` python
sig = getSignature("136482208") sig = getSignature("136482208")
print(sig) print(sig)
``` ```
%% Output %% Output
['2723-A'] ['2723-A']
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
getSignatureAC("AC14251814")
```
%% Output
https://obv-at-oenb.alma.exlibrisgroup.com/view/sru/43ACC_ONB?version=1.2&query=alma.local_control_field_009=AC14251814&operation=searchRetrieve
['Cod. Ser. n. 14767']
%% Cell type:code id: tags:
``` python
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment