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.

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

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.0.1
File Size Uploaded Provenance Actions
opac_client-1.0.1.tar.gz 55.4 kB Without provenance Details for opac_client-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 94.9 kB

Release files / opac_client-1.0.1.tar.gz

Download URL opac_client-1.0.1.tar.gz
Size 55.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8440f2d80cc28a9376b062c7f8bcd7e9e0b43cea9638f2c07a8378795260cdfd
BLAKE2b-256 checksum
How to use checksums
b55c3ef3f3a5f69ac3e04206b845d75c84dfef80a95b0966f9fd19e92f52b5f9
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.1-py3-none-any.whl

Download URL opac_client-1.0.1-py3-none-any.whl
Size 39.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9d4c36bfc55d194c2a249f5aad37dbc89a433a0b1d4b0168c704e54dd40c9d6
BLAKE2b-256 checksum
How to use checksums
399c2300f3bce9ce95362d2458f4f5305f003f02545f55445a6666acd249be8c
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.1

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