Crawl4AI는 LLM, AI 에이전트 및 데이터 파이프라인에 맞게 제작된 고속, AI 지원 웹 크롤러입니다. 이 프로젝트는 완전한 오픈 소스이며 유연하고 실시간 성능을 위해 구축되어 개발자에게 비교할 수 없는 속도, 정확성 및 배포 편의성을 제공합니다.
pip install -U crawl4ai
crawl4ai-setup
crawl4ai-doctor
docker pull unclecode/crawl4ai:0.6.0-rN
docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g unclecode/crawl4ai:0.6.0-rN
# webUI:http://localhost:11235/playground
import asyncio
from crawl4ai import *
async def main():
async with AsyncWebCrawler() as crawler:
result = await crawler.arun(
url="https://www.nbcnews.com/business",
)
print(result.markdown)
if __name__ == "__main__":
asyncio.run(main())
crwl https://www.nbcnews.com/business -o markdown
crwl https://docs.crawl4ai.com --deep-crawl bfs --max-pages 10
crwl https://www.example.com/products -q "Extract all product prices"
import os
import asyncio
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, LLMConfig
from crawl4ai.extraction_strategy import LLMExtractionStrategy
from pydantic import BaseModel, Field
class OpenAIModelFee(BaseModel):
model_name: str = Field(..., description="Name of the OpenAI model.")
input_fee: str = Field(..., description="Fee for input token for the OpenAI model.")
output_fee: str = Field(..., description="Fee for output token for the OpenAI model.")
async def main():
browser_config = BrowserConfig(verbose=True)
run_config = CrawlerRunConfig(
word_count_threshold=1,
extraction_strategy=LLMExtractionStrategy(
llm_config = LLMConfig(provider="openai/gpt-4o", api_token=os.getenv('OPENAI_API_KEY')),
schema=OpenAIModelFee.schema(),
extraction_type="schema",
instruction="""From the crawled content, extract all mentioned model names along with their fees for input and output tokens.
Do not miss any models in the entire content. One extracted model JSON format should look like this:
{"model_name": "GPT-4", "input_fee": "US$10.00 / 1M tokens", "output_fee": "US$30.00 / 1M tokens"}."""
),
cache_mode=CacheMode.BYPASS,
)
async with AsyncWebCrawler(config=browser_config) as crawler:
result = await crawler.arun(
url='https://openai.com/api/pricing/',
config=run_config
)
print(result.extracted_content)
if __name__ == "__main__":
asyncio.run(main())
지리적 위치, 언어 및 시간대를 설정하여 실제 지역별 콘텐츠를 가져옵니다.
run_config = CrawlerRunConfig(
url="https://browserleaks.com/geo",
locale="en-US",
timezone_id="America/Los_Angeles",
geolocation=GeolocationConfig(
latitude=34.0522,
longitude=-118.2437,
accuracy=10.0,
)
)
HTML 테이블을 CSV 또는 pandas DataFrame으로 직접 추출합니다.
results = await crawler.arun(
url="https://coinmarketcap.com/?page=1",
config=crawl_config
)
raw_df = pd.DataFrame()
for result in results:
if result.success and result.media["tables"]:
raw_df = pd.DataFrame(
result.media["tables"][0]["rows"],
columns=result.media["tables"][0]["headers"],
)
break
페이지 시작 시 예열된 브라우저 인스턴스를 사용하여 대기 시간 및 메모리 사용량 감소
모델 컨텍스트 프로토콜을 통해 Claude Code와 같은 AI 도구에 연결합니다.
claude mcp add --transport sse c4ai-sse http://localhost:11235/mcp/sse
Crawl4AI는 활발한 오픈 소스 커뮤니티 지원을 받으며 코드 기여, 문제 보고 및 제안을 환영합니다. 이 프로젝트는 Apache 2.0 라이선스를 따르며 완전한 오픈 소스이며 무료로 사용할 수 있습니다.
Crawl4AI는 특히 AI 시대의 맥락에서 웹 크롤링 기술의 최신 발전을 나타냅니다. 기존 크롤러의 모든 기능을 제공할 뿐만 아니라 현대 AI 애플리케이션에 맞게 특별히 최적화되어 데이터 과학자, AI 연구원 및 개발자에게 이상적인 선택입니다. 오픈 소스 특성과 활발한 커뮤니티를 통해 Crawl4AI는 웹 데이터 추출 기술의 민주화와 표준화를 추진하고 있습니다.