Tủ GitHub repo xịn
Avatar unclecode

GitHub repo xịn · Vui Coding chọn

unclecode/crawl4ai

🚀🤖 Crawl4AI: Open-source LLM Friendly Web Crawler & Scraper. --- 🚀 Crawl4AI Cloud API — Closed Beta (Launching Soon) Reliable, large-scale web extraction, now built to be drastically more cost-effective than any of the existing solutions.

80,3 NGitHub stars
8,3 NForks
176Open issues
1Lượt nhấp GitHub
PythonNgôn ngữ chính

Tóm tắt nhanh

Repo này làm được gì?

🚀🤖 Crawl4AI: Open-source LLM Friendly Web Crawler & Scraper. --- 🚀 Crawl4AI Cloud API — Closed Beta (Launching Soon) Reliable, large-scale web extraction, now built to be drastically more cost-effective than any of the existing solutions.

Mô tả từ GitHub

🚀🤖 Crawl4AI: Open-source LLM Friendly Web Crawler & Scraper. Don't be shy, join here: https://discord.gg/jP8KfhDhyN

Bắt đầu với repo

Cài đặt và sử dụng

Hướng dẫn cài đặt

pip install -U crawl4ai

Hướng dẫn sử dụng

You can check the project structure in the directory [docs/examples](https://github.com/unclecode/crawl4ai/tree/main/docs/examples). Over there, you can find a variety of examples; here, some popular examples are shared. 📝 Heuristic Markdown Generation with Clean and Fit Markdown

import asyncio
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
from crawl4ai.content_filter_strategy import PruningContentFilter, BM25ContentFilter
from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator

async def main():
    browser_config = BrowserConfig(
        headless=True,
        verbose=True,
    )
    run_config = CrawlerRunConfig(
        cache_mode=CacheMode.ENABLED,
        markdown_generator=DefaultMarkdownGenerator(
            content_filter=PruningContentFilter(threshold=0.48, threshold_type="fixed", min_word_threshold=0)
        ),
        # markdown_generator=DefaultMarkdownGenerator(
        #     content_filter=BM25ContentFilter(user_query="WHEN_WE_FOCUS_BASED_ON_A_USER_QUERY", bm25_threshold=1.0)
        # ),
    )

    async with AsyncWebCrawler(config=browser_config) as crawler:
        result = await crawler.arun(
            url="https://docs.micronaut.io/4.9.9/guide/",
            config=run_config
        )
        print(len(result.markdown.raw_markdown))
        print(len(result.markdown.fit_markdown))

if __name__ == "__main__":
    asyncio.run(main())

🖥️ Executing JavaScript & Extract Structured Data without LLMs

import asyncio
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode
from crawl4ai import JsonCssExtractionStrategy
import json

async def main():
    schema = {
    "name": "KidoCode Courses",
    "baseSelector": "section.charge-methodology .w-tab-content > div",
    "fields": [
        {
            "name": "section_title",
            "selector": "h3.heading-50",
            "type": "text",
        },
        {
            "name": "section_description",
            "selector": ".charge-content",
            "type": "text",
        },
        {
            "name": "course_name",
            "selector": ".text-block-93",
            "type": "text",
        },
        {
            "name": "course_description",
            "selector": ".course-content-text",
            "type": "text",
        },
        {
            "name": "course_icon",
            "selector": ".image-92",
            "type": "attribute",
            "attribute": "src"
        }
    ]
}

    extraction_strategy = JsonCssExtractionStrategy(schema, verbose=True)

    browser_config = BrowserConfig(
        headless=False,
        verbose=True
    )
    run_config = CrawlerRunConfig(
        extraction_strategy=extraction_strategy,
        js_code=["""(async () => {const tabs = document.querySelectorAll("section.charge-methodology .tabs-menu-3 > div");for(let tab of tabs) {tab.scrollIntoView();tab.click();await new Promise(r => setTimeout(r, 500));}})();"""],
        cache_mode=CacheMode.BYPASS
    )

    async with AsyncWebCrawler(config=browser_config) as crawler:

        result = await crawler.arun(
            url="https://www.kidocode.com/degrees/technology",
            config=run_config
        )

        companies = json.loads(result.extracted_content)
        print(f"Successfully extracted {len(companies)} companies")
        print(json.dumps(companies[0], indent=2))


if __name__ == "__main__":
    asyncio.run(main())

📚 Extracting Structured Data with LLMs

import os
import asyncio
from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, LLMConfig
from crawl4ai 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 to
Đối chiếu README gốc
Mở trên GitHub

Cùng hệ sinh thái

Repo liên quan

project-based-learning

practical-tutorials/project-based-learning

Repository này tổng hợp các hướng dẫn học lập trình dựa trên dự án, giúp người mới nắm bắt cách xây dựng ứng dụng từ đầu theo nhiều ngôn ngữ. Đây là tài nguyên hữu ích để học cách lập trình trực quan và thực tế.

281,3 NPython

MoneyPrinterTurbo

harry0703/MoneyPrinterTurbo

GitHub repository MoneyPrinterTurbo là công cụ tự động tạo video ngắn độ phân giải cao dựa trên chủ đề hoặc từ khóa bằng AI, hỗ trợ nhiều hình ảnh, âm thanh và mô hình AI khác nhau. Nó giúp tối ưu hóa quá trình sản xuất video bằng các tính năng như tạo nội dung tự động, đa dạng định dạng và phát hành trực tiếp lên các

115,1 NPython

screenshot-to-code

abi/screenshot-to-code

repository này cung cấp công cụ chuyển đổi ảnh chụp màn hình, mockup hoặc thiết kế Figma thành mã nguồn sạch sẽ và chức năng sử dụng AI. Điểm mạnh là hỗ trợ đa ngăn xếp và tích hợp nhiều mô hình AI để tối ưu hoá chất lượng đầu ra.

76,7 NPython

last30days-skill

mvanhorn/last30days-skill

Repository này xây dựng một công cụ tìm kiếm dựa trên trí tuệ nhân tạo, tổng hợp dữ liệu từ Reddit, X, YouTube, HN, Polymarket và web để tạo ra các bản tóm tắt dựa trên thảo luận và bình chọn thực tế. Điểm nổi bật là khả năng truy cập nhiều nguồn dữ liệu và đánh giá nội dung dựa trên sự tương tác của người dùng.

60,5 NPython