문서

문서

ActiCrawl을 사용하여 웹 스크래핑 워크플로를 자동화하는 방법을 알아보세요

빠른 시작

단 몇 분만에 ActiCrawl을 시작하세요. 이 가이드는 첫 번째 웹 스크래핑 요청을 만드는 과정을 안내합니다.

사전 요구사항

시작하기 전에 다음 사항을 확인하세요:
- ActiCrawl 계정 (여기서 가입)
- API 키 (대시보드에서 생성)

첫 번째 요청

웹페이지를 스크래핑하는 가장 간단한 방법:

bash
curl -X POST https://api.acticrawl.com/v1/scrape \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "markdown"
  }'

YOUR_API_KEY를 실제 API 키로 교체하세요.

응답 형식

API는 JSON 응답을 반환합니다:

json
{
  "success": true,
  "data": {
    "content": "# Example Domain\n\n이 도메인은 예시용으로 사용됩니다...",
    "metadata": {
      "title": "Example Domain",
      "description": "문서용 예시 도메인",
      "url": "https://example.com"
    }
  },
  "usage": {
    "credits_used": 1,
    "credits_remaining": 99
  }
}

일반적인 사용 사례

1. 깔끔한 텍스트 추출 (마크다운)

LLM에 콘텐츠를 제공하기에 완벽합니다:

javascript
const response = await fetch('https://api.acticrawl.com/v1/scrape', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com/article',
    format: 'markdown',
    clean: true  // 광고, 네비게이션, 푸터 제거
  })
});

const data = await response.json();
console.log(data.data.content);

2. 구조화된 데이터 추출 (JSON)

특정 데이터 포인트 추출:

python
import requests

response = requests.post(
    'https://api.acticrawl.com/v1/scrape',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'url': 'https://example.com/product',
        'format': 'json',
        'schema': {
            'title': 'h1',
            'price': '.price',
            'description': '.product-description',
            'images': 'img[src]'
        }
    }
)

data = response.json()
print(data['data']['extracted'])

3. JavaScript 중심 사이트 처리

JavaScript 렌더링이 필요한 사이트의 경우:

ruby
require 'net/http'
require 'json'

uri = URI('https://api.acticrawl.com/v1/scrape')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'

request.body = {
  url: 'https://example.com/spa',
  format: 'html',
  wait_for: 'networkidle',  # 모든 네트워크 요청이 완료될 때까지 대기
  timeout: 30000
}.to_json

response = http.request(request)
data = JSON.parse(response.body)

고급 옵션

대기 전략

스크래퍼가 페이지를 준비됨으로 간주하는 시점 제어:

  • load - 페이지 로드 이벤트 대기 (가장 빠름)
  • domcontentloaded - DOM이 완전히 로드될 때까지 대기
  • networkidle - 네트워크가 유휴 상태가 될 때까지 대기 (SPA에 최적)
  • 사용자 정의 CSS 선택자 - 특정 요소 대기: wait_for: '#content'

프록시 사용

지역 제한 콘텐츠용 프록시 사용:

json
{
  "url": "https://example.com",
  "proxy": {
    "country": "US",
    "type": "residential"
  }
}

스크린샷

시각적 표현 캡처:

json
{
  "url": "https://example.com",
  "format": "screenshot",
  "screenshot_options": {
    "full_page": true,
    "type": "png"
  }
}

요청 제한

  • 무료 플랜: 초당 1개 요청
  • 기본 플랜: 초당 5개 요청
  • 프로 플랜: 초당 20개 요청
  • 전문가 플랜: 초당 50개 요청
  • 엔터프라이즈: 무제한

오류 처리

구현 시 항상 오류를 확인하세요:

javascript
try {
  const response = await fetch('https://api.acticrawl.com/v1/scrape', {
    // ... 요청 옵션
  });

  if (!response.ok) {
    throw new Error(`HTTP 오류! 상태: ${response.status}`);
  }

  const data = await response.json();

  if (!data.success) {
    console.error('스크래핑 실패:', data.error);
    return;
  }

  // 성공적인 응답 처리
  console.log(data.data.content);

} catch (error) {
  console.error('요청 실패:', error);
}

다음 단계

도움이 필요하신가요?