{"id":36530286,"url":"https://github.com/rohankarn35/htmlcapture","last_synced_at":"2026-01-12T03:00:02.245Z","repository":{"id":275049216,"uuid":"924904409","full_name":"rohankarn35/htmlcapture","owner":"rohankarn35","description":"htmlcapture – A Go package to capture high-quality screenshots from URLs, HTML files, or raw HTML strings. Supports dynamic HTML, CSS selectors, and Instagram-optimized sizes. ","archived":false,"fork":false,"pushed_at":"2025-02-07T20:00:00.000Z","size":48,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T21:18:20.647Z","etag":null,"topics":["chromedp","golang","html2image","htmlcapture","package"],"latest_commit_sha":null,"homepage":"","language":"Go","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/rohankarn35.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2025-01-30T21:09:12.000Z","updated_at":"2025-02-07T20:00:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5f55028-b3bf-423a-a6ee-71d2d75c4bd7","html_url":"https://github.com/rohankarn35/htmlcapture","commit_stats":null,"previous_names":["rohankarn35/htmlcapture"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rohankarn35/htmlcapture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohankarn35%2Fhtmlcapture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohankarn35%2Fhtmlcapture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohankarn35%2Fhtmlcapture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohankarn35%2Fhtmlcapture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohankarn35","download_url":"https://codeload.github.com/rohankarn35/htmlcapture/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohankarn35%2Fhtmlcapture/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28332829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"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":["chromedp","golang","html2image","htmlcapture","package"],"created_at":"2026-01-12T03:00:00.055Z","updated_at":"2026-01-12T03:00:02.239Z","avatar_url":"https://github.com/rohankarn35.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# htmlcapture\n\n## 📸 Overview\n\n**htmlcapture** is a Go package that captures high-quality screenshots from URLs, HTML files, or raw HTML strings. It is optimized for Instagram post sizes and supports dynamic HTML rendering.\n\n---\n\n[![GoDoc](https://pkg.go.dev/badge/github.com/rohankarn35/htmlcapture.svg)](https://pkg.go.dev/github.com/rohankarn35/htmlcapture)\n[![Go Report Card](https://goreportcard.com/badge/github.com/rohankarn35/htmlcapture)](https://goreportcard.com/report/github.com/rohankarn35/htmlcapture)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## 🚀 Installation\n\nTo install **htmlcapture**, use:\n\n```sh\ngo get github.com/rohankarn35/htmlcapture@latest\n```\n\n---\n\n## 📌 Features\n\n- ✅ Capture from **URL, HTML file, or raw HTML string**\n- ✅ Supports **dynamic HTML rendering** with external variables\n- ✅ Capture **specific elements** using **CSS selectors**\n- ✅ Default **Instagram-optimized** screenshot sizes\n- ✅ Uses **headless Chrome (chromedp)** for rendering\n\n---\n\n## 🛠 Usage\n\n### 1️⃣ **Basic Usage: Capture a Raw HTML String**\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n    \"github.com/rohankarn35/htmlcapture\"\n)\n\nfunc main() {\n    opts := htmlcapture.CaptureOptions{\n        Input: `\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eHello, World!\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e`,\n    }\n    img, err := htmlcapture.Capture(opts)\n    if err != nil {\n        fmt.Println(\"Error:\", err)\n        return\n    }\n    os.WriteFile(\"screenshot.png\", img, 0644)\n}\n```\n\n---\n\n### 2️⃣ **Capture an HTML File (With Dynamic Variables)**\n\n**Example: `template.html`**\n\n```html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eWelcome {{.User}}, to {{.Website}}!\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n**Go Code:**\n\n```go\npackage main\n\nimport (\n    \"github.com/rohankarn35/htmlcapture\"\n)\n\nfunc main() {\n    opts := htmlcapture.CaptureOptions{\n        Input: \"template.html\",\n        Variables: map[string]string{\n            \"User\": \"Alice\",\n            \"Website\": \"Wonderland\",\n        },\n    }\n    img, err := htmlcapture.Capture(opts)\n    if err != nil {\n        log.Fatalf(\"Error capturing screenshot: %v\", err)\n    }\n    os.WriteFile(\"screenshot.png\", img, 0644)\n}\n```\n\n---\n\n### 3️⃣ **Capture a Website URL**\n\n```go\npackage main\n\nimport (\n    \"github.com/rohankarn35/htmlcapture\"\n)\n\nfunc main() {\n    opts := htmlcapture.CaptureOptions{\n        Input: \"https://example.com\",\n        ViewportW: 1920,\n        ViewportH: 1080,\n    }\n    img, err := htmlcapture.Capture(opts)\n    if err != nil {\n        log.Fatalf(\"Error capturing screenshot: %v\", err)\n    }\n    os.WriteFile(\"screenshot.png\", img, 0644)\n}\n```\n\n---\n\n### 4️⃣ **Capture a Specific Element (CSS Selector)**\n\n```go\npackage main\n\nimport (\n    \"github.com/rohankarn35/htmlcapture\"\n)\n\nfunc main() {\n    opts := htmlcapture.CaptureOptions{\n        Input: \"https://example.com\",\n        Selector: \"#main-content\",\n    }\n    img, err := htmlcapture.Capture(opts)\n    if err != nil {\n        log.Fatalf(\"Error capturing screenshot: %v\", err)\n    }\n    os.WriteFile(\"screenshot.png\", img, 0644)\n}\n```\n\n---\n\n## 📝 Configuration Options\n\n| Option      | Type              | Default  | Description                                   |\n| ----------- | ----------------- | -------- | --------------------------------------------- |\n| `Input`     | string            | Required | URL, HTML string, or file path                |\n| `ViewportW` | int               | 1080     | Viewport width                                |\n| `ViewportH` | int               | 1350     | Viewport height                               |\n| `Selector`  | string            | \"\"       | CSS selector for capturing a specific element |\n| `Variables` | map[string]string | `{}`     | Key-value pairs for dynamic HTML              |\n\n---\n\n## 📖 License\n\nMIT License\n\n---\n\n## 💡 Future Enhancements\n\n- ✅ Add **PDF output support** 📄\n- ✅ Improve **performance optimizations** 🚀\n- ✅ Additional **image quality controls** 🎨\n\n---\n\n**Contributions are welcome! Feel free to open issues or submit pull requests.** 😃\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohankarn35%2Fhtmlcapture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohankarn35%2Fhtmlcapture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohankarn35%2Fhtmlcapture/lists"}