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 gleanly # core
pip install "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).
Search
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.0a2
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 |
|---|---|---|---|---|
| gleanly-0.1.0a2.tar.gz | 140.3 kB | With provenance | Details for gleanly-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gleanly-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for gleanly-0.1.0a2-py3-none-any.whl |
Total release size: 230.0 kB
Release files / gleanly-0.1.0a2.tar.gz
| Download URL | gleanly-0.1.0a2.tar.gz |
|---|---|
| Size | 140.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0cb5f9c96d66e0a97e97e6ceeed908de7a61e8a09abce2d33dace0473aceb049
|
|
BLAKE2b-256 checksum How to use checksums |
ef724a754b516dde6a646a04fcad31dd3ab010f4f214f5df522609188349fbdf
|
| 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 logRelease files / gleanly-0.1.0a2-py3-none-any.whl
| Download URL | gleanly-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2db5ef92911fe810d1ce6d7664d43c316739f3ae73866e834db75968e10732d
|
|
BLAKE2b-256 checksum How to use checksums |
58261362a15d2d165db6a8ffb3ade303f427f8db6e5eb630e8885c4a2588dd4e
|
| 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 logSecurity for gleanly 0.1.0a2
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.
Attestation for gleanly-0.1.0a2.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 logA 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.