Chuyển đến nội dung
Skillpedia
Thu thập dữ liệu web29k · #9577

browser-automation

Skill này làm gì

Skill này cung cấp cho agent các công cụ và mẫu để điều khiển trình duyệt bằng Playwright, nhằm thu thập dữ liệu hoặc hoàn thành các tác vụ web lặp lại. Dành cho người tự động hóa nghiên cứu web, thu thập dữ liệu hoặc công việc điền form.

Khi nào nên dùng

  • ✓Khi bạn muốn thu thập dữ liệu từ một trang web, chẳng hạn một bảng hoặc kết quả tìm kiếm.
  • ✓Khi bạn cần một tác vụ web nhiều bước, chẳng hạn điền form hoặc tải file.
  • ✓Khi bạn muốn tự động chụp ảnh màn hình hoặc PDF của các trang web.

Liên kết skill

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/skills/browser-automation/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/skills/browser-automation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi cần bạn thu thập tên và giá sản phẩm từ trang danh sách của cửa hàng này vào một bảng tính.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent điều khiển trình duyệt bằng Playwright, chờ trang tải xong, trích xuất nội dung và lưu kết quả. Các script hỗ trợ xây dựng trình thu thập dữ liệu và luồng điền form.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Browser Automation - POWERFUL

Overview

The Browser Automation skill provides comprehensive tools and knowledge for building production-grade web automation workflows using Playwright. This skill covers data extraction, form filling, screenshot capture, session management, and anti-detection patterns for reliable browser automation at scale.

When to use this skill:

  • Scraping structured data from websites (tables, listings, search results)
  • Automating multi-step browser workflows (login, fill forms, download files)
  • Capturing screenshots or PDFs of web pages
  • Extracting data from SPAs and JavaScript-heavy sites
  • Building repeatable browser-based data pipelines

When NOT to use this skill:

  • Writing browser tests or E2E test suites — use playwright-pro instead
  • Testing API endpoints — use api-test-suite-builder instead
  • Load testing or performance benchmarking — use performance-profiler instead

Why Playwright over Selenium or Puppeteer:

  • Auto-wait built in — no explicit sleep() or waitForElement() needed for most actions
  • Multi-browser from one API — Chromium, Firefox, WebKit with zero config changes
  • Network interception — block ads, mock responses, capture API calls natively
  • Browser contexts — isolated sessions without spinning up new browser instances
  • Codegen — playwright codegen records your actions and generates scripts
  • Async-first — Python async/await for high-throughput scraping

Core Competencies

1. Web Scraping Patterns

Selector priority (most to least reliable):

  1. data-testid, data-id, or custom data attributes — stable across redesigns
  2. #id selectors — unique but may change between deploys
  3. Semantic selectors: article, nav, main, section — resilient to CSS changes
  4. Class-based: .product-card, .price — brittle if classes are generated (e.g., CSS modules)
  5. Positional: nth-child(), nth-of-type() — last resort, breaks on layout changes

Use XPath only when CSS cannot express the relationship (e.g., ancestor traversal, text-based selection).

Pagination strategies: next-button, URL-based (?page=N), infinite scroll, load-more button. See data_extraction_recipes.md for complete pagination handlers and scroll patterns.

2. Form Filling & Multi-Step Workflows

Break multi-step forms into discrete functions per step. Each function fills fields, clicks "Next"/"Continue", and waits for the next step to load (URL change or DOM element).

Key patterns: login flows, multi-page forms, file uploads (including drag-and-drop zones), native and custom dropdown handling. See playwright_browser_api.md for complete API reference on fill(), select_option(), set_input_files(), and expect_file_chooser().

3. Screenshot & PDF Capture

  • Full page: await page.screenshot(path="full.png", full_page=True)
  • Element: await page.locator("div.chart").screenshot(path="chart.png")
  • PDF (Chromium only): await page.pdf(path="out.pdf", format="A4", print_background=True)
  • Visual regression: Take screenshots at known states, store baselines in version control with naming: {page}_{viewport}_{state}.png

See playwright_browser_api.md for full screenshot/PDF options.

4. Structured Data Extraction

Core extraction patterns:

  • Tables to JSON — Extract <thead> headers and <tbody> rows into dictionaries
  • Listings to arrays — Map repeating card elements using a field-selector map (supports ::attr() for attributes)
  • Nested/threaded data — Recursive extraction for comments with replies, category trees

See data_extraction_recipes.md for complete extraction functions, price parsing, data cleaning utilities, and output format helpers (JSON, CSV, JSONL).

5. Cookie & Session Management

  • Save/restore cookies: context.cookies() and context.add_cookies()
  • Full storage state (cookies + localStorage): context.storage_state(path="state.json") to save, browser.new_context(storage_state="state.json") to restore

Best practice: Save state after login, reuse across scraping sessions. Check session validity before starting a long job — make a lightweight request to a protected page and verify you are not redirected to login. See playwright_browser_api.md

Câu hỏi thường gặp

Đây có phải để kiểm thử website không?

Không. Các bài test trình duyệt do một skill khác đảm nhận, tên là playwright-pro.

Nó có xử lý được các trang nặng JavaScript không?

Có. Nó bao gồm việc trích xuất dữ liệu từ các single-page app tải nội dung bằng JavaScript.

Nó có chạy trên nhiều trình duyệt không?

Có. Playwright hỗ trợ Chromium, Firefox và WebKit qua cùng một giao diện.

Chi tiết

Mô tả gốc của tác giả

Use for browser automation, scraping, form filling or structured extraction from web pages. Builds scrapers with scraping_toolkit.py and form flows with form_automation_builder.py. Browser testing: playwright-pro.

repo: alirezarezvani/claude-skills

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9577
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự