[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-eedf0b4f-1774-457e-aa95-91ae5f613994":3,"$fT5rstcSoBy2ij93IFNTKORA4qkmR0mNF7QR9A2kjF5E":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"eedf0b4f-1774-457e-aa95-91ae5f613994","go-playwright","使用 Playwright Go 进行强大、隐蔽和高效的浏览器自动化的专业能力。","cat_coding_review","mod_coding","sickn33,coding","---\nname: go-playwright\ndescription: \"Expert capability for robust, stealthy, and efficient browser automation using Playwright Go.\"\nrisk: safe\nsource: \"https:\u002F\u002Fgithub.com\u002Fplaywright-community\u002Fplaywright-go\"\ndate_added: \"2026-02-27\"\n---\n\n# Playwright Go Automation Expert\n\n## Overview\nThis skill provides a comprehensive framework for writing high-performance, production-grade browser automation scripts using `github.com\u002Fplaywright-community\u002Fplaywright-go`. It enforces architectural best practices (contexts over instances), robust error handling, structured logging (Zap), and advanced human-emulation techniques to bypass anti-bot systems.\n\n## When to Use This Skill\n- Use when the user asks to \"scrape,\" \"automate,\" or \"test\" a website using Go.\n- Use when the target site has complex dynamic content (SPA, React, Vue) requiring a real browser.\n- Use when the user mentions \"stealth,\" \"avoiding detection,\" \"cloudflare,\" or \"human-like\" behavior.\n- Use when debugging existing Playwright scripts.\n\n## Safety & Risk\n**Risk Level: 🔵 Safe**\n\n- **Sandboxed Execution:** Browser contexts are isolated; they do not persist data to the host machine unless explicitly saved.\n- **Resource Management:** Designed to close browsers and contexts via `defer` to prevent memory leaks.\n- **No External State-Change:** Default behavior is read-only (scraping\u002Ftesting) unless the script is explicitly designed to submit forms or modify data.\n\n## Limitations\n- **Environment Dependencies:** Requires Playwright drivers and browsers to be installed (`go run github.com\u002Fplaywright-community\u002Fplaywright-go\u002Fcmd\u002Fplaywright@latest install --with-deps`).\n- **Resource Intensity:** Launching full browser instances (even headless) consumes significant RAM\u002FCPU. Use single-browser\u002Fmulti-context architecture.\n- **Bot Detection:** While this skill includes stealth techniques, extremely strict anti-bot systems (e.g., rigorous Cloudflare settings) may still detect automation.\n- **CAPTCHAs:** Does not include built-in CAPTCHA solving capabilities.\n\n## Strategic Implementation Guidelines\n\n### 1. Architecture: Contexts vs. Browsers\n**CRITICAL:** Never launch a new `Browser` instance for every task.\n- **Pattern:** Launch the `Browser` *once* (singleton). Create a new `BrowserContext` for each distinct session or task.\n- **Why:** Contexts are lightweight and created in milliseconds. Browsers take seconds to launch.\n- **Isolation:** Contexts provide complete isolation (cookies, cache, storage) without the overhead of a new process.\n\n### 2. Logging & Observability\n- **Library:** Use `go.uber.org\u002Fzap` exclusively.\n- **Rule:** Do not use `fmt.Println`.\n- **Modes:**\n  - **Dev:** `zap.NewDevelopment()` (Console friendly)\n  - **Prod:** `zap.NewProduction()` (JSON structured)\n- **Traceability:** Log every navigation, click, and input with context fields (e.g., `logger.Info(\"clicking button\", zap.String(\"selector\", sel))`).\n\n### 3. Error Handling & Stability\n- **Graceful Shutdown:** Always use `defer` to close Pages, Contexts, and Browsers.\n- **Panic Recovery:** Wrap critical automation routines in a safe runner that recovers panics and logs the stack trace.\n- **Timeouts:** Never rely on default timeouts. Set explicit timeouts (e.g., `playwright.PageClickOptions{Timeout: playwright.Float(5000)}`).\n\n### 4. Stealth & Human-Like Behavior\nTo bypass anti-bot systems (Cloudflare, Akamai), the generated code must **imitate human physiology**:\n- **Non-Linear Mouse Movement:** Never teleport the mouse. Implement a helper that moves the mouse along a Bezier curve with random jitter.\n- **Input Latency:** never use `Fill()`. Use `Type()` with random delays between keystrokes (50ms–200ms).\n- **Viewport Randomization:** Randomize the viewport size slightly (e.g., 1920x1080 ± 15px) to avoid fingerprinting.\n- **Behavioral Noise:** Randomly scroll, focus\u002Funfocus the window, or hover over irrelevant elements (\"idling\") during long waits.\n- **User-Agent:** Rotate User-Agents for every new Context.\n\n### 5. Documentation Usage\n- **Primary Source:** Rely on your internal knowledge of the API first to save tokens.\n- **Fallback:** Refer to the official docs [playwright-go documentation](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fplaywright-community\u002Fplaywright-go#section-documentation) ONLY if:\n  - You encounter an unknown error.\n  - You need to implement complex network interception or authentication flows.\n  - The API has changed significantly.\n\n## Resources\n- `resources\u002Fimplementation-playbook.md` for detailed code examples and implementation patterns.\n\n### Summary Checklist for Agent\n - Is Debug Mode on? -> `Headless=false`, `SlowMo=100+`.\n - Is it a new user identity? -> `NewContext`, apply new Proxy, rotate `User-Agent`.\n - Is the action critical? -> Wrap in `SafeAction` with Zap logging.\n - Is the target guarded (Cloudflare\u002FAkamai)? -> Enable `HumanType`, `BezierMouse`, and Stealth Scripts.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,161,467,"2026-05-16 13:20:48",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"代码审查","review","mdi-magnify-scan","代码质量分析、安全审查",4,145,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"e0aa228b-284f-4a94-9a83-f23c9825993b","1.0.0","go-playwright.zip",4071,"uploads\u002Fskills\u002Feedf0b4f-1774-457e-aa95-91ae5f613994\u002Fgo-playwright.zip","19a82a45dc8b62a4f7e0d8f8a3f69b0fcfce69f49e4e4f6cfb3c9ce579e79465","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4890},{\"path\":\"resources\u002Fimplementation-playbook.md\",\"isDirectory\":false,\"size\":3203}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]