😫 Vấn đề (The Pain Point)
Bạn là Marketer/Agency cần nghiên cứu đối thủ. Sếp đưa danh sách 100 website đối thủ và yêu cầu: “Chụp lại trang chủ của họ để phân tích”.
Cách làm thủ công:
- Mở trình duyệt.
- Gõ URL.
- Đợi load.
- Dùng extension chụp ảnh cuộn trang (Full Page Screenshot).
- Lưu file, đặt tên.
- Lặp lại 100 lần.
Cực kỳ mất thời gian và nhàm chán!
🚀 Giải pháp Agentic (The Solution)
Sử dụng một “Robot duyệt web” (Puppeteer) để tự động đi qua từng link và chụp ảnh lại.
Tính năng:
- Full Page Capture: Chụp từ đầu đến chân website, tự động cuộn (scroll) để load hết ảnh.
- Batch Processing: Đọc file
urls.txtchứa 1000 link cũng chạy tốt. - Smart Waiting: Tự động đợi mạng load xong mới chụp (tránh chụp trang trắng).
- High Resolution: Giả lập màn hình Desktop Full HD hoặc 4K.
(Kết quả là folder chứa hàng trăm ảnh website)
🤖 Engineering Prompt (Copy & Paste)
Copy đoạn prompt này để tạo công cụ:
**Role:** Node.js Automation Developer
**Task:** Create a command-line tool to batch capture screenshots of websites using Puppeteer.
**Requirements:**
1. **Tech Stack:** Node.js, `puppeteer` (headless Chrome).
2. **Input:** A text file `urls.txt` containing a list of URLs (one per line).
3. **Features:**
* **Batch Processing:** Iterate through the list of URLs.
* **Full Page Capture:** Option to capture the entire scrollable height of the page, or just the viewport.
* **Smart Waiting:** Wait for the network to be idle (`networkidle0`) to ensure images/styles load before capturing.
* **Naming:** Save images as `domain-timestamp.png` inside a `screenshots` folder.
* **Viewport:** Simulate a high-res desktop connection (e.g., 1920x1080).
4. **Deliverables:**
* `screenshot_batch.js`: The automation script.
* `package.json`: Dependencies.
* `urls.txt`: Sample input file.
* `run.bat` (optional): To run `npm install && node screenshot_batch.js`.
**Context:** Used by agencies/marketers to capture landing pages of competitors for research or portfolio archival.
🧠 Giải mã Prompt (Anatomy)
- Tech Stack: Tại sao chọn Node.js/Puppeteer thay vì Python/Selenium? Vì Puppeteer (do Google build) điều khiển Chrome mượt mà hơn và chụp ảnh Full Page (cuộn trang) tốt hơn rất nhiều.
- Smart Waiting:
networkidle0là keyword quan trọng để robot biết khi nào web load xong hẳn (không còn request mạng nào trong 500ms) rồi mới chụp.
🛠️ Hướng dẫn sử dụng (Zero-Touch Guide)
- Copy Prompt ở trên và paste vào AI.
- Đợi AI tạo file. Bạn sẽ thấy file
screenshot_batch.jsvàpackage.json. - Vào file
urls.txt, dán danh sách link web bạn muốn chụp (mỗi dòng 1 link). - Chạy file
run.bat(AI sẽ tạo để chạynpm install). - Ngồi chơi và xem folder
screenshotstự động đầy lên!
Lưu ý: Cần cài đặt Node.js trên máy tính trước khi dùng workflow này.