Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

gleanly

All-in-one, open-source text acquisition for AI. Turn any URL or file into clean Markdown with a trust score, compliance metadata ("can I use this for AI training?") and provenance for every block. One pip install, one process, no Docker.

pip install --pre gleanly            # alpha: --pre is needed until 1.0
pip install --pre "gleanly[pdf,ocr]" # + PDFs and OCR (OCR also needs Tesseract installed)

Alpha: the API may still change between 0.x releases (see the versioning policy). Feedback and bug reports are very welcome.

from gleanly import load

doc = load("https://example.com/article")
print(doc.markdown)  # clean Markdown (tables and code preserved)
print(doc.quality.score)  # 0..1, comparable across web, PDF and OCR sources
print(doc.compliance.ai_use)  # "allowed" | "disallowed" | "unclear" + conditions and evidence
print(doc.blocks[0].provenance)  # URL + XPath + character span in the Markdown
print(doc.fetch_trace.steps)  # every fetch-ladder step that was tried, and why

Async: doc = await aload(url). Batch with shared rate limits: async with Client() as c: ...

CLI:

gleanly load https://example.com/article -o article.md
gleanly load https://example.com/article -o article.json   # full Document as JSON

PDFs, scans and images

pip install "gleanly[pdf]"   # native PDFs
pip install "gleanly[ocr]"   # + OCR; also install Tesseract (github.com/tesseract-ocr/tesseract)
doc = load("report.pdf")  # or "scan.jpg", or a URL serving either
doc.blocks[3].provenance  # kind="pdf" (text layer) or "image" (OCR), page, bbox
doc.quality.ocr_confidence  # Tesseract's word confidence, when OCR was used
doc.quality.extraction_confidence  # PDFs: agreement between the text layer and OCR

What gleanly adds on top of plain PDF text extraction and Tesseract:

  • Headings, lists and re-joined hyphenation; running headers, footers and page numbers learned across pages and removed.
  • Scanned pages inside a PDF are OCR'd automatically.
  • Text-layer check: pages whose hidden text looks broken, plus a small sample, are compared with OCR; a layer that does not match the page (a wrong font map, a poor old OCR layer) is replaced and the page is named in a warning.
  • OCR clean-up tuned on a benchmark: 0.77% characters wrong on held-out pages against 16.1% for plain Tesseract, mostly by fixing shadows, faint print and phone photos (bench/README.md).
from gleanly import search

resp = search("tide pool animals")  # Wikipedia by default; Brave/SearXNG when configured
for r in resp.results:
    print(r.score, r.hit.url, r.hit.engines)  # which engines found it, and at what rank
    print(r.document.quality.score, r.document.compliance.ai_use)  # every result is a full Document
gleanly search "tide pool animals" -n 5 --exclude-disallowed

Backends use official APIs only: Wikipedia (no key), Brave Search (BRAVE_API_KEY) and your own SearXNG instance (SEARXNG_URL). Results from several engines are merged with reciprocal rank fusion, then every page is fetched through load() (robots.txt, rate limits, trust score, AI-use verdict, provenance). Ranking v0 combines query relevance, the fused rank and the page's trust score; it will be tuned on a search benchmark.

Source agreement (experimental): resp.agreement lists numeric and date facts that two or more results agree on (corroborated) or contradict (conflicts), each quoting every source with its exact location. It is strict on purpose (a conflict needs nearly the same sentence with a different number) and reports candidates to check, not verdicts.

Status

Phases 1 (web pages) and 2 (PDFs and OCR) are done; Phase 3 (search) is in progress. See docs/status.md.

Capability Status
Web page → Markdown + metadata ✅ v0
Fetch ladder: HTTP → embedded data (JSON-LD, __NEXT_DATA__) → Playwright ✅ v0
robots.txt (RFC 9309), per-host rate limiting, honest User-Agent ✅
Compliance: TDMRep, ai.txt, noai, AI-crawler opt-outs, license detection, PII flags ✅ v0
Quality report + trust score ✅ v0 (uncalibrated)
Native PDFs (gleanly[pdf]): headings, lists, page + bounding-box provenance, running headers removed ✅ v0
OCR for images and scanned PDF pages (gleanly[ocr] + Tesseract): background flattening, text-size normalisation, layout self-check, OCR confidence in the trust score ✅ v0
search() with reranking and cross-source agreement Phase 3
Archive fallbacks, crawling, server mode, benchmark Phase 4

Ethics by design

The library identifies itself honestly (gleanly/<version> (+project URL)), respects robots.txt by default, rate-limits per host and never tries to evade blocks: no fingerprint spoofing, CAPTCHA solving or proxy rotation. When a site refuses access, you get a clear explanation in FetchError.trace.

Install (development)

uv sync                       # core + dev tools
uv run pytest
uv sync --extra browser && uv run playwright install chromium   # optional rung 3

License

Apache-2.0

Contributing and security

See CONTRIBUTING.md, docs/architecture.md, SECURITY.md and the CHANGELOG.

Metadata

Release files for gleanly 0.1.0a1

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

Source distribution (sdist)

Source distribution for gleanly 0.1.0a1
File Size Uploaded Provenance Actions
gleanly-0.1.0a1.tar.gz 139.6 kB With provenance Details for gleanly-0.1.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gleanly 0.1.0a1
File Interpreter ABI Platform Actions
gleanly-0.1.0a1-py3-none-any.whl Python 3 none any Details for gleanly-0.1.0a1-py3-none-any.whl

Total release size: 229.0 kB

Release files / gleanly-0.1.0a1.tar.gz

Download URL gleanly-0.1.0a1.tar.gz
Size 139.6 kB
Tags Source
SHA-256 checksum
How to use checksums
147f73c2f5fce4198e67004f8459736e1a9a16e8c8be20f989ba385513e928c7
BLAKE2b-256 checksum
How to use checksums
aa4d2a28162e959ba86d9a855a04b7ba93e98aade58a46b5d48a46837fe477be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / gleanly-0.1.0a1-py3-none-any.whl

Download URL gleanly-0.1.0a1-py3-none-any.whl
Size 89.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
355f947a0f8235642198e5acb7f4915cc2770ecfea722aabe21f10a9797390e6
BLAKE2b-256 checksum
How to use checksums
e838d6d1dc4f9c79cccbd94d0d9ab762dfdac71a410188f956ebdb2035ad8281
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for gleanly 0.1.0a1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gleanly-0.1.0a1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

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