---
title: "Crawllee Node.js Scraper: Cài đặt chi tiết từ đầu và kiểm tra hoạt động thực tế"
description: "Hướng dẫn cài đặt Crawlee Node.js Scraper từ đầu trên Cloud VPS với PlaywrightCrawler, tích hợp ProxyPool Việt Nam/USA và kiểm tra hoạt động thực tế."
canonical: "https://thuecloud.vn/crawllee-node-js-scraper-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te"
markdown_url: "https://thuecloud.vn/crawllee-node-js-scraper-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:24.712Z"
updated_at: "2026-11-22T16:18:22.184Z"
site: "ThueCloud.Vn"
estimated_tokens: 1724
---
# Crawllee Node.js Scraper: Cài đặt chi tiết từ đầu và kiểm tra hoạt động thực tế

> Hướng dẫn cài đặt Crawlee Node.js Scraper từ đầu trên Cloud VPS với PlaywrightCrawler, tích hợp ProxyPool Việt Nam/USA và kiểm tra hoạt động thực tế.

- Canonical HTML: https://thuecloud.vn/crawllee-node-js-scraper-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te
- Markdown URL: https://thuecloud.vn/crawllee-node-js-scraper-cai-dat-chi-tiet-tu-dau-va-kiem-tra-hoat-dong-thuc-te.md
- Organization: ThueCloud.Vn
- Support Email: support@thuecloud.vn
- Hotline: 03333 499 48
- Published: 2026-11-22
- Updated: 2026-11-22

## Mục lục

- Lựa chọn Crawler phù hợp trong Crawlee
- Cài đặt Crawlee Node.js Scraper từ đầu
  - Khởi tạo dự án trên Cloud VPS (Node.js 20+)
  - Viết Scraper tích hợp ProxyConfiguration và SessionPool
- Câu hỏi thường gặp (FAQ)
  - Tại sao Crawlee tự động tạo thư mục storage/ và lưu file vào đó?
  - SessionPool trong Crawlee giúp ích gì khi dùng Proxy?
  - Có thể chạy Crawlee với CheerioCrawler kết hợp Proxy SOCKS5 không?

Khi xây dựng hệ thống thu thập dữ liệu quy mô vừa và lớn, việc tự viết vòng lặp quản lý hàng đợi, retry, lưu trữ JSON và xoay proxy từ con số không rất dễ phát sinh lỗi. **Crawlee** (phát triển bởi Apify trên nền tảng Node.js/TypeScript) cung cấp sẵn `CheerioCrawler` siêu nhẹ và `PlaywrightCrawler` giả lập trình duyệt, kết hợp hoàn hảo với [Proxy Việt Nam](https://thuecloud.vn/proxy-viet-nam) và [Proxy USA](https://thuecloud.vn/proxy-usa) trên [Cloud VPS Việt Nam](https://thuecloud.vn/vps-viet-nam).

> **Tóm tắt nhanh (TL;DR):**
> - Crawlee tích hợp sẵn `RequestQueue`, `Dataset` và `ProxyConfiguration` với cơ chế tự động loại bỏ proxy bị chặn (SessionPool).
> - Chọn `CheerioCrawler` cho trang HTML tĩnh (tốn ít RAM) và `PlaywrightCrawler` cho trang SPA render bằng JavaScript.
> - Kiểm tra hoạt động thực tế qua log `AutoscaledPool` để thấy hệ thống tự điều chỉnh concurrency theo tải CPU/RAM của VPS.
> - *Cập nhật: 11/2026*

## Lựa chọn Crawler phù hợp trong Crawlee

| Loại Crawler | Công nghệ lõi | Mức tiêu thụ RAM | Trường hợp sử dụng tối ưu |
| :--- | :--- | :--- | :--- |
| `CheerioCrawler` | HTTP client + `cheerio` (jQuery-like) | ~100–250 MB cho 50 luồng | Trang SSR, HTML tĩnh, API JSON |
| `PlaywrightCrawler` | Chromium/Firefox Headless | ~2–4 GB cho 8–10 luồng | Trang React/Vue/Next.js cần chạy JS |

Sau khi cài đặt xong, bạn có thể tham khảo [tinh chỉnh hiệu năng Crawlee trên Production](https://thuecloud.vn/crawllee-node-js-scraper-tinh-chinh-tham-so-hieu-nang-va-gioi-han-tai-nguyen-production) hoặc [bảo mật Httpx Async Proxy Pool](https://thuecloud.vn/httpx-async-proxy-pool-tang-cuong-bao-mat-phan-quyen-va-thiet-lap-giam-sat-canh-bao) cho các tác vụ Python song song.

## Cài đặt Crawlee Node.js Scraper từ đầu

### 1. Khởi tạo dự án trên Cloud VPS (Node.js 20+)

```bash
mkdir my-crawlee-bot && cd my-crawlee-bot
npm init -y
npm install crawlee playwright
npx playwright install chromium
```

### 2. Viết Scraper tích hợp `ProxyConfiguration` và `SessionPool`

Tạo file `main.mjs`:

```javascript
import { PlaywrightCrawler, ProxyConfiguration } from 'crawlee';

const proxyConfiguration = new ProxyConfiguration({
  proxyUrls: [
    'http://user1:pass1@103.x.x.1:8080',
    'http://user1:pass1@45.x.x.2:8080',
  ],
});

const crawler = new PlaywrightCrawler({
  proxyConfiguration,
  useSessionPool: true,
  persistCookiesPerSession: true,
  maxConcurrency: 4,
  async requestHandler({ request, page, log, pushData }) {
    const title = await page.title();
    log.info(`Crawled: ${request.url} | Title: ${title}`);
    await pushData({ url: request.url, title });
  },
});

await crawler.run(['https://example.com', 'https://news.ycombinator.com']);
```

Chạy thử nghiệm bằng lệnh `node main.mjs`. Kết quả trích xuất sẽ được lưu tự động thành các file JSON trong thư mục `storage/datasets/default/`.

> **Chạy Crawlee ổn định với Proxy sạch & VPS NVMe tại ThueCloud.Vn:**
> Hạ tầng **KVM Enterprise NVMe tại vn-hn** với **VAT 0%**, **SLA 99,9%**, **hoàn tiền 07 ngày**.
> - Gói **VPS VN 2** (`78.000đ`–`90.000đ/tháng`) và **VPS VN 3** (`139.000đ`–`170.000đ/tháng`) kết hợp **Proxy VN/USA từ 70.000đ/tháng**.
> - Xem chi tiết tại [bảng giá ThueCloud](https://thuecloud.vn/pricing).

## Câu hỏi thường gặp (FAQ)

### Tại sao Crawlee tự động tạo thư mục `storage/` và lưu file vào đó?
Đây là thiết kế lưu trữ cục bộ mặc định giúp tiến trình crawl có thể tạm dừng và chạy tiếp (resume) từ đúng hàng đợi `request_queues` mà không bị mất dữ liệu nếu VPS khởi động lại.

### `SessionPool` trong Crawlee giúp ích gì khi dùng Proxy?
Mỗi session gắn liền một bộ cookie và một IP proxy. Nếu trang đích trả về mã lỗi `403` hoặc `429`, Crawlee tự động đánh dấu session đó bị hỏng (`session.retire()`) và chuyển sang cặp proxy/cookie mới cho lần thử lại.

### Có thể chạy Crawlee với `CheerioCrawler` kết hợp Proxy SOCKS5 không?
Có. Bạn chỉ cần truyền chuỗi `socks5://user:pass@host:port` vào mảng `proxyUrls` của `ProxyConfiguration`, Crawlee sẽ tự động xử lý tầng tunnel.

## References / Sources

- https://crawlee.dev/docs/quick-start
- https://crawlee.dev/docs/guides/proxy-management

---

## Navigation & Machine-Readable Endpoints

- [Site Summary (llms.txt)](https://thuecloud.vn/llms.txt)
- [Full Technical Reference (llms-full.txt)](https://thuecloud.vn/llms-full.txt)
- [Pricing Catalog (Markdown)](https://thuecloud.vn/pricing.md)
- [Blog & Technical Guides (Markdown)](https://thuecloud.vn/blog.md)
- [XML Sitemap](https://thuecloud.vn/sitemap.xml)
