Spider 스크래퍼

Spider 스크래퍼 (SpiderTool)

CrewAI의 SpiderTool은 Spider를 사용하는 도구예요. Spider는 가장 빠른 오픈소스 스크래퍼·크롤러로, LLM-ready 데이터를 반환합니다. 어떤 웹사이트든 순수 HTML, markdown, 메타데이터 또는 텍스트로 변환하고, AI로 커스텀 액션을 사용한 크롤링도 지원해요.

출처: 문서

본문

Spider는 가장 빠른 오픈소스 스크래퍼·크롤러로, LLM-ready 데이터를 반환합니다. 어떤 웹사이트든 순수 HTML, markdown, 메타데이터 또는 텍스트로 변환하며, AI를 사용한 커스텀 액션으로 크롤링할 수도 있어요.

설치 (Installation)

SpiderTool을 사용하려면 Spider SDK와 crewai[tools] SDK를 모두 설치해야 합니다.

pip install spider-client 'crewai[tools]'

예시 (Example)

이 예시는 SpiderTool을 사용해 에이전트가 웹사이트를 스크래핑·크롤링하게 하는 방법을 보여줍니다. Spider API에서 반환되는 데이터는 이미 LLM-ready이므로 별도 정리가 필요 없어요.

from crewai_tools import SpiderTool

def main():
    spider_tool = SpiderTool()

    searcher = Agent(
        role="Web Research Expert",
        goal="Find related information from specific URL's",
        backstory="An expert web researcher that uses the web extremely well",
        tools=[spider_tool],
        verbose=True,
    )

    return_metadata = Task(
        description="Scrape https://spider.cloud with a limit of 1 and enable metadata",
        expected_output="Metadata and 10 word summary of spider.cloud",
        agent=searcher
    )

    crew = Crew(
        agents=[searcher],
        tasks=[
            return_metadata,
        ],
        verbose=2
    )

    crew.kickoff()

if __name__ == "__main__":
    main()

인자 (Arguments)

Argument Type Description
api_key string Spider API 키 지정. 지정하지 않으면 환경변수에서 SPIDER_API_KEY를 찾습니다.
params object 요청을 위한 선택적 파라미터. 기본값은 {"return_format": "markdown"}으로 LLM에 콘텐츠를 최적화합니다.
request string 수행할 요청 유형 (http, chrome, smart). smart는 기본적으로 HTTP를 사용하며 필요 시 JavaScript 렌더링으로 전환합니다.
limit int 웹사이트당 크롤링할 최대 페이지 수. 무제한이면 0으로 설정하거나 생략.
depth int 최대 크롤링 깊이. 제한 없음은 0.
cache bool 반복 실행 속도를 높이기 위한 HTTP 캐싱 활성화. 기본값은 true.
budget object 크롤링 페이지에 대한 경로 기반 한도 설정. 예: 루트 페이지만 {"*":1}.
locale string 요청의 로케일. 예: en-US.
cookies string 요청을 위한 HTTP 쿠키.
stealth bool 탐지를 피하기 위해 Chrome 요청에 스텔스 모드 활성화. 기본값은 true.
headers object 모든 요청에 대한 key-value 쌍의 HTTP 헤더 맵.
metadata bool 페이지와 콘텐츠에 대한 메타데이터 저장. AI 상호운용성을 돕습니다. 기본값은 false.
viewport object Chrome 뷰포트 크기 설정. 기본값은 800x600.
encoding string 인코딩 유형 지정. 예: UTF-8, SHIFT_JIS.
subdomains bool 크롤링에 서브도메인 포함. 기본값은 false.
user_agent string 커스텀 HTTP user agent. 기본값은 랜덤 에이전트.
store_data bool 요청에 대한 데이터 저장 활성화. 설정 시 storageless를 재정의. 기본값은 false.
gpt_config object AI가 크롤링 액션을 생성할 수 있게 하며, "prompt"용 배열로 선택적 체이닝 단계 지원.
fingerprint bool Chrome에 대한 고급 지문(fingerprinting) 활성화.
storageless bool AI 임베딩을 포함한 모든 데이터 저장 방지. 기본값은 false.
readability bool Mozilla의 readability로 콘텐츠를 읽기용으로 전처리. LLM에 콘텐츠를 개선.
return_format string 데이터를 반환할 형식: markdown, raw, text, html2text. 기본 페이지 형식은 raw 사용.
proxy_enabled bool 네트워크 수준 차단을 피하기 위한 고성능 프록시 활성화.
query_selector string 마크업에서 콘텐츠 추출을 위한 CSS 쿼리 선택자.
full_resources bool 웹사이트에 연결된 모든 리소스 다운로드.
request_timeout int 요청 타임아웃(초) (5-60). 기본값은 30.
run_in_background bool 요청을 백그라운드로 실행. 데이터 저장과 대시보드 크롤링 트리거에 유용. storageless가 설정되면 효과 없음.

더 알아보기 (Learn more)