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.1.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.1.0
File Size Uploaded Provenance Actions
opac_client-1.1.0.tar.gz 56.1 kB Without provenance Details for opac_client-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 96.1 kB

Release files / opac_client-1.1.0.tar.gz

Download URL opac_client-1.1.0.tar.gz
Size 56.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6aec221c29de0e1aba940f158b98cd2a20ffaa7d51d150d0b59f3f086ef7a335
BLAKE2b-256 checksum
How to use checksums
4968cd1e9e84db7866f25d0c1dede2c87bc574fd411595cff120c383a6944f4c
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.1.0-py3-none-any.whl

Download URL opac_client-1.1.0-py3-none-any.whl
Size 39.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae42cab0c5f86df6a032c9bff01a09064205b6d7e401b883f3c7b20b5f0738e4
BLAKE2b-256 checksum
How to use checksums
10fd2e72458476402e6415c27941ba181ff7a71f45048ca0877dbb164518ee04
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.1.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