Skip to content

herrkaefer/anything2md

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anything2md

 __ __ _ ___ __ ____ _____ __ __/ /_/ /_ (_)___ ____ |__ \ ____ ___ ____/ / / __ `/ __ \/ / / / __/ __ \/ / __ \/ __ `/_/ // __ `__ \/ __ / / /_/ / / / / /_/ / /_/ / / / / / / / /_/ / __// / / / / / /_/ / \__,_/_/ /_/\__, /\__/_/ /_/_/_/ /_/\__, /____/_/ /_/ /_/\__,_/ /____/ /____/ 

CI PyPI version Python >=3.10 License: MIT

Python package and CLI for converting URLs or local documents into Markdown using Cloudflare Markdown Conversion APIs.

Install

From PyPI with uv:

uv add anything2md

Or from PyPI (pip):

pip install anything2md

Cloudflare Token Setup

Create a Cloudflare API Token for the target account and include these permissions:

  • Workers AI -- Read
  • Browser Rendering -- Edit

Usage

import anything2md mdconverter = anything2md(account_id="xxx", api_token="xxx") result = mdconverter.transform("https://example.com") result = mdconverter.transform("https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf") result = mdconverter.transform("https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg") # Browser Rendering advanced options for webpage URLs result = mdconverter.transform( "https://example.com", url_strategy="browser", wait_until="networkidle2", reject_request_pattern=["/^.*\\.(css)$/", "/analytics/"], ) print(result.markdown)

Supported Formats

Based on Cloudflare docs, current supported extensions include:

pdf, jpeg/jpg, png, webp, svg, html/htm, xml, csv, docx, xlsx, xlsm, xlsb, xls, et, ods, odt, numbers

url via Browser Rendering Markdown endpoint.

Local Usage

Install dependencies:

uv sync
export CLOUDFLARE_ACCOUNT_ID="your_account_id" export CLOUDFLARE_API_TOKEN="your_api_token" uv run anything2md https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf uv run anything2md https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg -o output.md uv run anything2md https://example.com uv run anything2md https://example.com --url-strategy browser --wait-until networkidle2 --reject-request-pattern '/^.*\.(css)$/' --reject-request-pattern '/analytics/'

References

Cloudflare docs:

License

MIT