Skip to main content

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.

Los filtros language, country y medium reciben el valor numérico exacto de la opción del catálogo (por ejemplo, language="04" para inglés). Cuando se usan, el cliente consulta el formulario avanzado. Si son los únicos criterios, agrega * a normal_any_field, como requiere el formulario AbsysNet para búsquedas solo con desplegables.

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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opac-client 1.2.0
File Size Uploaded Provenance Actions
opac_client-1.2.0.tar.gz 56.4 kB Without provenance Details for opac_client-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opac-client 1.2.0
File Interpreter ABI Platform Actions
opac_client-1.2.0-py3-none-any.whl Python 3 none any Details for opac_client-1.2.0-py3-none-any.whl

Total release size: 96.4 kB

Release files / opac_client-1.2.0.tar.gz

Download URL opac_client-1.2.0.tar.gz
Size 56.4 kB
Tags Source
SHA-256 checksum
How to use checksums
870708d4f5f9968c235d22bb09ae31bb0d27a5b5ed305425ff5a50f88387ced1
BLAKE2b-256 checksum
How to use checksums
21471816f7c8774b52bcd2701fef1bc919cb70ac4d29ad81881d98a3884d76d1
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.2.0-py3-none-any.whl

Download URL opac_client-1.2.0-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
695575a4797c496a70edee165acc64888fbe2c9c49bfe666425607a9daca9b9b
BLAKE2b-256 checksum
How to use checksums
f59fc159d59518e1115d22eb481a748d2d8d21eb7ca7c05cf989dcdb631181a1
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.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page