{"id":50708056,"url":"https://github.com/posit-dev/nokap","last_synced_at":"2026-06-09T13:01:59.073Z","repository":{"id":362403578,"uuid":"1258882136","full_name":"posit-dev/nokap","owner":"posit-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-07T22:56:15.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-08T00:22:00.541Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://posit-dev.github.io/nokap/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posit-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-04T02:23:10.000Z","updated_at":"2026-06-07T22:56:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/posit-dev/nokap","commit_stats":null,"previous_names":["rich-iannone/gun","rich-iannone/nokap","posit-dev/nokap"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/posit-dev/nokap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fnokap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fnokap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fnokap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fnokap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posit-dev","download_url":"https://codeload.github.com/posit-dev/nokap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fnokap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34107866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-09T13:01:58.990Z","updated_at":"2026-06-09T13:01:59.061Z","avatar_url":"https://github.com/posit-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# nokap\n\n_Screenshots and PDFs from web pages. Powered by headless Chrome._\n\n[![Python Versions](https://img.shields.io/pypi/pyversions/nokap.svg)](https://pypi.org/project/nokap/)\n[![PyPI](https://img.shields.io/pypi/v/nokap?logo=python\u0026logoColor=white\u0026color=orange)](https://pypi.org/project/nokap/)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://choosealicense.com/licenses/mit/)\n[![CI](https://github.com/posit-dev/nokap/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/posit-dev/nokap/actions/workflows/ci.yml)\n\n\u003c/div\u003e\n\n**nokap** captures screenshots and PDFs from web pages (or local HTML) using headless Chrome via the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). It doesn't need Selenium or Playwright. We use just one lightweight dependency (`websockets`).\n\n## Installation\n\n```bash\npip install nokap\n```\n\nChrome or Chromium must be installed on the system. **nokap** will hunt it down pretty quickly.\n\n## Quick Start\n\n```python\nimport nokap\n\n# Screenshot a URL\nnokap.webshot(\"https://example.com\", \"example.png\")\n\n# Save as PDF\nnokap.webshot(\"https://example.com\", \"example.pdf\")\n\n# Screenshot with a CSS selector (captures just that element)\nnokap.webshot(\"https://example.com\", \"header.png\", selector=\"h1\")\n\n# From an HTML string (great for table libraries)\nnokap.from_html(\"\u003ch1\u003eHello, world!\u003c/h1\u003e\", \"hello.png\")\n```\n\n## API\n\n### `nokap.webshot()`\n\nTake a screenshot or PDF of a web page.\n\n```python\nnokap.webshot(\n    url,                # URL or local file path\n    file=\"webshot.png\", # Output path (.png, .jpg, .webp, .pdf)\n    *,\n    vwidth=992,         # Viewport width (px)\n    vheight=744,        # Viewport height (px)\n    selector=None,      # CSS selector to capture\n    cliprect=None,      # Clip rectangle (x, y, width, height)\n    expand=0,           # Padding around selector (px)\n    delay=0.2,          # Wait after page load (seconds)\n    zoom=1,             # Scale factor (2 = retina)\n    useragent=None,     # Custom User-Agent string\n)\n```\n\n### `nokap.from_html()`\n\nRender an HTML string to an image or PDF. Designed for integration with table/report libraries.\n\n```python\nnokap.from_html(\n    html,               # HTML content\n    file=\"webshot.png\", # Output path\n    *,\n    selector=\"html\",    # CSS selector to capture\n    **kwargs,           # All webshot() options\n)\n```\n\n### `nokap.close()`\n\nShut down the background Chrome process. Called automatically at exit, but available for explicit cleanup.\n\n```python\nnokap.close()\n```\n\n## How It Works\n\nnokap communicates directly with Chrome over the [Chrome DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) via WebSockets. No browser driver binaries, no heavyweight automation frameworks.\n\nThe architecture:\n\n1. **Launch**: Finds and starts headless Chrome with a random debugging port\n2. **Connect**: Opens a WebSocket to Chrome's CDP endpoint\n3. **Capture**: Creates a tab, navigates, waits, then calls `Page.captureScreenshot` or `Page.printToPDF`\n4. **Cleanup**: Closes the tab; Chrome stays running for reuse until `nokap.close()` or process exit\n\n## Features\n\n| Feature | Details |\n|---------|---------|\n| **Image formats** | PNG, JPEG, WebP |\n| **PDF generation** | Configurable page size, margins, orientation |\n| **CSS selectors** | Capture specific elements (or union of multiple) |\n| **Zoom/scale** | Produce retina-quality (2×, 3×) images |\n| **Expand/padding** | Add whitespace around captured elements |\n| **Local HTML** | Render HTML strings or local `.html` files |\n| **Viewport control** | Set width/height for responsive layouts |\n| **Custom User-Agent** | Override the browser UA string |\n| **Auto-cleanup** | Chrome process managed via `atexit` |\n| **Jupyter-safe** | Works in notebooks (no event loop conflicts) |\n\n## Configuration\n\n| Environment Variable | Purpose |\n|---------------------|---------|\n| `CHROME_PATH` | Override Chrome binary location |\n\n## Requirements\n\n- Python ≥ 3.10\n- Chrome or Chromium installed on the system\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fnokap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposit-dev%2Fnokap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fnokap/lists"}