Cliente OPAC para AbsysNet
Cliente de solo lectura, sin dependencias externas, para buscar recursos en catálogos compatibles con AbsysNet OPAC. Incluye una API Python, una interfaz de línea de comandos y un servidor HTTP opcional.
Requiere Python 3.10 o posterior.
Instalación
Desde la raíz del proyecto:
python -m pip install -e .
La instalación editable crea los comandos opac y opac-server.
Línea de comandos
Buscar «capital» y mostrar los primeros 10 resultados como JSON:
opac "https://gestiona.comunidad.madrid/biblio_publicas/cgi-bin/abnetopac" capital --items-per-page 10 --json
También se pueden usar filtros:
opac "https://gestiona.comunidad.madrid/biblio_publicas/cgi-bin/abnetopac" \
--title "Madrid histórico" \
--author "Sara Medialdea" \
--language spa
Opciones frecuentes:
--page N: consulta una página concreta.--all: recorre las páginas disponibles.--max-pages N: limita las páginas de--all(por defecto, 100).--items-per-page N: cantidad de registros por página (por defecto, 100).--json: imprime los resultados en JSON.--expert-search,--title,--author,--editorial,--subject,--collection,--genre.--min-publish-date,--max-publish-date,--language,--country,--medium,--sort-by.--timeout SEGUNDOS: tiempo máximo de espera por solicitud.
Sin instalar el paquete, se puede invocar desde la raíz con:
PYTHONPATH=src python -m opac.cli "https://gestiona.comunidad.madrid/biblio_publicas/cgi-bin/abnetopac" capital --items-per-page 10 --json
Uso desde Python
from opac import OpacClient, SearchQuery
catalog_url = (
"https://gestiona.comunidad.madrid/"
"biblio_publicas/cgi-bin/abnetopac"
)
client = OpacClient(catalog_url)
query = SearchQuery(normal_any_field="capital", items_per_page=10)
page = client.search(query)
for result in page.items:
print(result.title, result.author, result.year)
if page.next_page_url:
print("Siguiente página:", page.next_page_url)
# Recuperar varias páginas, con un límite para controlar las solicitudes.
results = client.search_all(query, max_pages=3)
print("Recursos recuperados:", len(results))
SearchQuery admite estos campos opcionales: normal_any_field, expert_any_field, title, author, editorial, subject, collection, genre, min_publish_date, max_publish_date, language, country, medium, sort_by e items_per_page.
Cada elemento de SearchResults.items es un SearchResult con los campos url, title, author, titn, language, year, resource_type, description y cover_url. Los campos textuales no siempre están presentes en los registros del catálogo.
Descargar un contenido binario
get_bytes() descarga el recurso identificado por MLKOB y devuelve el cuerpo sin decodificarlo. Por ejemplo, para guardar una cubierta:
from pathlib import Path
image_data = client.get_bytes("1615031543737")
Path("cubierta.jpg").write_bytes(image_data)
Usa la extensión correspondiente al formato que entregue el catálogo. El cliente conserva las cookies y sigue redirecciones HTTP y meta Refresh.
Servidor HTTP opcional
Configura OPAC_URL con una o varias URL de catálogos separadas por espacios y ejecuta el servidor:
OPAC_URL="https://gestiona.comunidad.madrid/biblio_publicas/cgi-bin/abnetopac" \
OPAC_HOST=127.0.0.1 OPAC_PORT=8000 OPAC_MAX_PAGES=10 opac-server
El servidor expone GET /search. Los nombres de los parámetros son los campos de SearchQuery:
curl --get http://127.0.0.1:8000/search \
--data-urlencode "normal_any_field=capital" \
--data-urlencode "language=spa"
Variables de entorno:
OPAC_URL: requerido; URL o URLs de catálogos separadas por espacios.OPAC_HOST: dirección de escucha (por defecto,127.0.0.1).OPAC_PORT: puerto (por defecto,8000).OPAC_MAX_PAGES: máximo de páginas por catálogo (por defecto,10; máximo,100).
Pruebas
Desde la raíz del repositorio:
PYTHONPATH=src python -m unittest discover -s tests -v
Licencia
Consulta el archivo LICENSE.
Metadata
Release files for opac-client 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opac_client-1.0.0.tar.gz | 55.4 kB | Without provenance | Details for opac_client-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opac_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for opac_client-1.0.0-py3-none-any.whl |
Total release size: 94.8 kB
Release files / opac_client-1.0.0.tar.gz
| Download URL | opac_client-1.0.0.tar.gz |
|---|---|
| Size | 55.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b52abf523da37cb18e29d3475cdcab67c1f74a8dcf0e137f59ccd400e74808d2
|
|
BLAKE2b-256 checksum How to use checksums |
f8d6d76a8e626d84298a624052f3f74181fd24bf963772641cd075965aca229f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / opac_client-1.0.0-py3-none-any.whl
| Download URL | opac_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 39.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a61979676d99d8036ada5068376f7874a78693341a560bc8affd47d0167b5ccc
|
|
BLAKE2b-256 checksum How to use checksums |
8600bb13d1e7bab295fe6a44e0f6e33898ec1cd1f924fd38e5bf5cc2138b1177
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for opac-client 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.