repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/config.py
crawl4ai/config.py
import os from dotenv import load_dotenv load_dotenv() # Load environment variables from .env file # Default provider, ONLY used when the extraction strategy is LLMExtractionStrategy DEFAULT_PROVIDER = "openai/gpt-4o" DEFAULT_PROVIDER_API_KEY = "OPENAI_API_KEY" MODEL_REPO_BRANCH = "new-release-0.0.2" # Provider-mode...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_url_seeder.py
crawl4ai/async_url_seeder.py
""" async_url_seeder.py Fast async URL discovery for Crawl4AI Features -------- * Common-Crawl streaming via httpx.AsyncClient (HTTP/2, keep-alive) * robots.txt β†’ sitemap chain (.gz + nested indexes) via async httpx * Per-domain CDX result cache on disk (~/.crawl4ai/<index>_<domain>_<hash>.jsonl) * Optional HEAD-only ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/link_preview.py
crawl4ai/link_preview.py
""" Link Extractor for Crawl4AI Extracts head content from links discovered during crawling using URLSeeder's efficient parallel processing and caching infrastructure. """ import asyncio import fnmatch from typing import Dict, List, Optional, Any from .async_logger import AsyncLogger from .async_url_seeder import Asy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/__init__.py
crawl4ai/__init__.py
# __init__.py import warnings from .async_webcrawler import AsyncWebCrawler, CacheMode # MODIFIED: Add SeedingConfig and VirtualScrollConfig here from .async_configs import BrowserConfig, CrawlerRunConfig, HTTPCrawlerConfig, LLMConfig, ProxyConfig, GeolocationConfig, SeedingConfig, VirtualScrollConfig, LinkPreviewConf...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/types.py
crawl4ai/types.py
from typing import TYPE_CHECKING, Union # Logger types AsyncLoggerBase = Union['AsyncLoggerBaseType'] AsyncLogger = Union['AsyncLoggerType'] # Crawler core types AsyncWebCrawler = Union['AsyncWebCrawlerType'] CacheMode = Union['CacheModeType'] CrawlResult = Union['CrawlResultType'] CrawlerHub = Union['CrawlerHubType'...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/adaptive_crawler.py
crawl4ai/adaptive_crawler.py
""" Adaptive Web Crawler for Crawl4AI This module implements adaptive information foraging for efficient web crawling. It determines when sufficient information has been gathered to answer a query, avoiding unnecessary crawls while ensuring comprehensive coverage. """ from abc import ABC, abstractmethod from typing i...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/browser_adapter.py
crawl4ai/browser_adapter.py
# browser_adapter.py """ Browser adapter for Crawl4AI to support both Playwright and undetected browsers with minimal changes to existing codebase. """ from abc import ABC, abstractmethod from typing import List, Dict, Any, Optional, Callable import time import json # Import both, but use conditionally try: from ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/proxy_strategy.py
crawl4ai/proxy_strategy.py
from typing import List, Dict, Optional from abc import ABC, abstractmethod from itertools import cycle import os ########### ATTENTION PEOPLE OF EARTH ########### # I have moved this config to async_configs.py, kept it here, in case someone still importing it, however # be a dear and follow `from crawl4ai import Pro...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/install.py
crawl4ai/install.py
import subprocess import sys import asyncio from .async_logger import AsyncLogger, LogLevel from pathlib import Path import os import shutil # Initialize logger logger = AsyncLogger(log_level=LogLevel.DEBUG, verbose=True) def setup_home_directory(): """Set up the .crawl4ai folder structure in the user's home dire...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/markdown_generation_strategy.py
crawl4ai/markdown_generation_strategy.py
from abc import ABC, abstractmethod from typing import Optional, Dict, Any, Tuple from .models import MarkdownGenerationResult from .html2text import CustomHTML2Text # from .types import RelevantContentFilter from .content_filter_strategy import RelevantContentFilter import re from urllib.parse import urljoin # Pre-co...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/__version__.py
crawl4ai/__version__.py
# crawl4ai/__version__.py # This is the version that will be used for stable releases __version__ = "0.7.8" # For nightly builds, this gets set during build process __nightly_version__ = None
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/cache_context.py
crawl4ai/cache_context.py
from enum import Enum class CacheMode(Enum): """ Defines the caching behavior for web crawling operations. Modes: - ENABLED: Normal caching behavior (read and write) - DISABLED: No caching at all - READ_ONLY: Only read from cache, don't write - WRITE_ONLY: Only write to cache, don't read ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/extraction_strategy.py
crawl4ai/extraction_strategy.py
from abc import ABC, abstractmethod import inspect from typing import Any, List, Dict, Optional, Tuple, Pattern, Union from concurrent.futures import ThreadPoolExecutor, as_completed import json import time from enum import IntFlag, auto from .prompts import PROMPT_EXTRACT_BLOCKS, PROMPT_EXTRACT_BLOCKS_WITH_INSTRUCTIO...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/hub.py
crawl4ai/hub.py
# crawl4ai/hub.py from abc import ABC, abstractmethod from typing import Dict, Type, Union import logging import importlib from pathlib import Path import inspect logger = logging.getLogger(__name__) class BaseCrawler(ABC): def __init__(self): self.logger = logging.getLogger(self.__class__.__name__) ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/dfs_strategy.py
crawl4ai/deep_crawling/dfs_strategy.py
# dfs_deep_crawl_strategy.py from typing import AsyncGenerator, Optional, Set, Dict, List, Tuple from ..models import CrawlResult from .bfs_strategy import BFSDeepCrawlStrategy # noqa from ..types import AsyncWebCrawler, CrawlerRunConfig from ..utils import normalize_url_for_deep_crawl class DFSDeepCrawlStrategy(BFS...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/bfs_strategy.py
crawl4ai/deep_crawling/bfs_strategy.py
# bfs_deep_crawl_strategy.py import asyncio import logging from datetime import datetime from typing import AsyncGenerator, Optional, Set, Dict, List, Tuple from urllib.parse import urlparse from ..models import TraversalStats from .filters import FilterChain from .scorers import URLScorer from . import DeepCrawlStrat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/base_strategy.py
crawl4ai/deep_crawling/base_strategy.py
from __future__ import annotations from abc import ABC, abstractmethod from typing import AsyncGenerator, Optional, Set, List, Dict from functools import wraps from contextvars import ContextVar from ..types import AsyncWebCrawler, CrawlerRunConfig, CrawlResult, RunManyReturn class DeepCrawlDecorator: """Decorat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/scorers.py
crawl4ai/deep_crawling/scorers.py
from abc import ABC, abstractmethod from typing import List, Dict, Optional from dataclasses import dataclass from urllib.parse import urlparse, unquote import re import logging from functools import lru_cache from array import array import ctypes import platform PLATFORM = platform.system() # Pre-computed scores for ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/crazy.py
crawl4ai/deep_crawling/crazy.py
from __future__ import annotations # I just got crazy, trying to wrute K&R C but in Python. Right now I feel like I'm in a quantum state. # I probably won't use this; I just want to leave it here. A century later, the future human race will be like, "WTF?" # ------ Imports That Will Make You Question Reality ------ # ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/filters.py
crawl4ai/deep_crawling/filters.py
from abc import ABC, abstractmethod from typing import List, Pattern, Set, Union from urllib.parse import urlparse from array import array import re import logging from functools import lru_cache import fnmatch from dataclasses import dataclass import weakref import math from collections import defaultdict from typing ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/__init__.py
crawl4ai/deep_crawling/__init__.py
# deep_crawling/__init__.py from .base_strategy import DeepCrawlDecorator, DeepCrawlStrategy from .bfs_strategy import BFSDeepCrawlStrategy from .bff_strategy import BestFirstCrawlingStrategy from .dfs_strategy import DFSDeepCrawlStrategy from .filters import ( FilterChain, ContentTypeFilter, DomainFilter, ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/deep_crawling/bff_strategy.py
crawl4ai/deep_crawling/bff_strategy.py
# best_first_crawling_strategy.py import asyncio import logging from datetime import datetime from typing import AsyncGenerator, Optional, Set, Dict, List, Tuple from urllib.parse import urlparse from ..models import TraversalStats from .filters import FilterChain from .scorers import URLScorer from . import DeepCrawl...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/components/crawler_monitor.py
crawl4ai/components/crawler_monitor.py
import time import uuid import threading import psutil from datetime import datetime, timedelta from typing import Dict, Optional, List import threading from rich.console import Console from rich.layout import Layout from rich.panel import Panel from rich.table import Table from rich.text import Text from rich.live imp...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/crawlers/__init__.py
crawl4ai/crawlers/__init__.py
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/crawlers/google_search/__init__.py
crawl4ai/crawlers/google_search/__init__.py
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/crawlers/google_search/crawler.py
crawl4ai/crawlers/google_search/crawler.py
from crawl4ai import BrowserConfig, AsyncWebCrawler, CrawlerRunConfig, CacheMode from crawl4ai.hub import BaseCrawler from crawl4ai.utils import optimize_html, get_home_folder, preprocess_html_for_schema from crawl4ai import JsonCssExtractionStrategy from pathlib import Path import json import os from typing import Dic...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/crawlers/amazon_product/__init__.py
crawl4ai/crawlers/amazon_product/__init__.py
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/crawlers/amazon_product/crawler.py
crawl4ai/crawlers/amazon_product/crawler.py
from crawl4ai.hub import BaseCrawler __meta__ = { "version": "1.2.0", "tested_on": ["amazon.com"], "rate_limit": "50 RPM", "schema": {"product": ["name", "price"]} } class AmazonProductCrawler(BaseCrawler): async def run(self, url: str, **kwargs) -> str: try: self.logger.info(f...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/_typing.py
crawl4ai/html2text/_typing.py
class OutCallback: def __call__(self, s: str) -> None: ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/cli.py
crawl4ai/html2text/cli.py
import argparse import sys from . import HTML2Text, __version__, config def main() -> None: baseurl = "" class bcolors: HEADER = "\033[95m" OKBLUE = "\033[94m" OKGREEN = "\033[92m" WARNING = "\033[93m" FAIL = "\033[91m" ENDC = "\033[0m" BOLD = "\033[1m...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/__main__.py
crawl4ai/html2text/__main__.py
from .cli import main main()
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/utils.py
crawl4ai/html2text/utils.py
import html.entities from typing import Dict, List, Optional from . import config unifiable_n = { html.entities.name2codepoint[k]: v for k, v in config.UNIFIABLE.items() if k != "nbsp" } def hn(tag: str) -> int: if tag[0] == "h" and len(tag) == 2: n = tag[1] if "0" < n <= "9": ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/config.py
crawl4ai/html2text/config.py
import re # Use Unicode characters instead of their ascii pseudo-replacements UNICODE_SNOB = False # Marker to use for marking tables for padding post processing TABLE_MARKER_FOR_PAD = "special_marker_for_table_padding" # Escape all special characters. Output is less readable, but avoids # corner case formatting iss...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/__init__.py
crawl4ai/html2text/__init__.py
"""html2text: Turn HTML into equivalent Markdown-structured text.""" import html.entities import html.parser import re import string import urllib.parse as urlparse from textwrap import wrap from typing import Dict, List, Optional, Tuple, Union from . import config from ._typing import OutCallback from .elements impo...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/html2text/elements.py
crawl4ai/html2text/elements.py
from typing import Dict, Optional class AnchorElement: __slots__ = ["attrs", "count", "outcount"] def __init__(self, attrs: Dict[str, Optional[str]], count: int, outcount: int): self.attrs = attrs self.count = count self.outcount = outcount class ListElement: __slots__ = ["name"...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/js_snippet/__init__.py
crawl4ai/js_snippet/__init__.py
import os # Create a function get name of a js script, then load from the CURRENT folder of this script and return its content as string, make sure its error free def load_js_script(script_name): # Get the path of the current script current_script_path = os.path.dirname(os.path.realpath(__file__)) # Get t...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/script/c4a_result.py
crawl4ai/script/c4a_result.py
""" Result classes for C4A-Script compilation Clean API design with no exceptions """ from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import List, Dict, Any, Optional import json class ErrorType(Enum): SYNTAX = "syntax" SEMANTIC = "semantic" R...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/script/__init__.py
crawl4ai/script/__init__.py
""" C4A-Script: A domain-specific language for web automation in Crawl4AI """ from .c4a_compile import C4ACompiler, compile, validate, compile_file from .c4a_result import ( CompilationResult, ValidationResult, ErrorDetail, WarningDetail, ErrorType, Severity, Suggestion ) __all__ = [ ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/script/c4ai_script.py
crawl4ai/script/c4ai_script.py
""" 2025-06-03 By Unclcode: C4A-Script Language Documentation Feeds Crawl4AI via CrawlerRunConfig(js_code=[ ... ]) – no core modifications. """ from __future__ import annotations import pathlib, re, sys, textwrap from dataclasses import dataclass from typing import Any, Dict, List, Union from lark import Lark, Tr...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/script/c4a_compile.py
crawl4ai/script/c4a_compile.py
""" Clean C4A-Script API with Result pattern No exceptions - always returns results """ from __future__ import annotations import pathlib import re from typing import Union, List, Optional # JSON_SCHEMA_BUILDER is still used elsewhere, # but we now also need the new script-builder prompt. from ..prompts import GENERA...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/llmtxt.py
crawl4ai/legacy/llmtxt.py
import os from pathlib import Path import re from typing import Dict, List, Tuple, Optional, Any import json from tqdm import tqdm import time import psutil import numpy as np from rank_bm25 import BM25Okapi from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.stem import WordNetLemmatize...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/docs_manager.py
crawl4ai/legacy/docs_manager.py
import requests import shutil from pathlib import Path from crawl4ai.async_logger import AsyncLogger from crawl4ai.llmtxt import AsyncLLMTextManager class DocsManager: def __init__(self, logger=None): self.docs_dir = Path.home() / ".crawl4ai" / "docs" self.local_docs = Path(__file__).parent.parent...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/crawler_strategy.py
crawl4ai/legacy/crawler_strategy.py
from abc import ABC, abstractmethod from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.opt...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/cli.py
crawl4ai/legacy/cli.py
import click import sys import asyncio from typing import List from .docs_manager import DocsManager from .async_logger import AsyncLogger logger = AsyncLogger(verbose=True) docs_manager = DocsManager(logger) def print_table(headers: List[str], rows: List[List[str]], padding: int = 2): """Print formatted table w...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/version_manager.py
crawl4ai/legacy/version_manager.py
# version_manager.py from pathlib import Path from packaging import version from . import __version__ class VersionManager: def __init__(self): self.home_dir = Path.home() / ".crawl4ai" self.version_file = self.home_dir / "version.txt" def get_installed_version(self): """Get the versi...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/database.py
crawl4ai/legacy/database.py
import os from pathlib import Path import sqlite3 from typing import Optional, Tuple DB_PATH = os.path.join(os.getenv("CRAWL4_AI_BASE_DIRECTORY", Path.home()), ".crawl4ai") os.makedirs(DB_PATH, exist_ok=True) DB_PATH = os.path.join(DB_PATH, "crawl4ai.db") def init_db(): global DB_PATH conn = sqlite3.connect(...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/__init__.py
crawl4ai/legacy/__init__.py
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/legacy/web_crawler.py
crawl4ai/legacy/web_crawler.py
import os, time os.environ["TOKENIZERS_PARALLELISM"] = "false" from pathlib import Path from .models import UrlModel, CrawlResult from .database import init_db, get_cached_url, cache_url from .utils import * from .chunking_strategy import * from .extraction_strategy import * from .crawler_strategy import * from typin...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/processors/pdf/processor.py
crawl4ai/processors/pdf/processor.py
import logging import re from abc import ABC, abstractmethod from datetime import datetime from pathlib import Path from time import time from dataclasses import dataclass, asdict, field from typing import Dict, List, Optional, Any, Union import base64 import tempfile from .utils import * from .utils import ( apply...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/processors/pdf/utils.py
crawl4ai/processors/pdf/utils.py
import re def apply_png_predictor(data, width, bits, color_channels): """Decode PNG predictor (PDF 1.5+ filter)""" bytes_per_pixel = (bits * color_channels) // 8 if (bits * color_channels) % 8 != 0: bytes_per_pixel += 1 stride = width * bytes_per_pixel scanline_length = stride + 1 ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/processors/pdf/__init__.py
crawl4ai/processors/pdf/__init__.py
from pathlib import Path import asyncio from dataclasses import asdict from crawl4ai.async_logger import AsyncLogger from crawl4ai.async_crawler_strategy import AsyncCrawlerStrategy from crawl4ai.models import AsyncCrawlResponse, ScrapingResult from crawl4ai.content_scraping_strategy import ContentScrapingStrategy fro...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/apps/linkdin/c4ai_discover.py
docs/apps/linkdin/c4ai_discover.py
#!/usr/bin/env python3 """ c4ai-discover β€” Stage‑1 Discovery CLI Scrapes LinkedIn company search + their people pages and dumps two newline‑delimited JSON files: companies.jsonl and people.jsonl. Key design rules ---------------- * No BeautifulSoup β€” Crawl4AI only for network + HTML fetch. * JsonCssExtractionStrategy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/apps/linkdin/c4ai_insights.py
docs/apps/linkdin/c4ai_insights.py
#!/usr/bin/env python3 """ Stage-2 Insights builder ------------------------ Reads companies.jsonl & people.jsonl (Stage-1 output) and produces: β€’ company_graph.json β€’ org_chart_<handle>.json (one per company) β€’ decision_makers.csv β€’ graph_view.html (interactive visualisation) Run: python c4ai_insigh...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/snippets/deep_crawl/1.intro.py
docs/snippets/deep_crawl/1.intro.py
import asyncio from typing import List from crawl4ai import ( AsyncWebCrawler, CrawlerRunConfig, BFSDeepCrawlStrategy, CrawlResult, FilterChain, DomainFilter, URLPatternFilter, ) # Import necessary classes from crawl4ai library: # - AsyncWebCrawler: The main class for web crawling. # - Cra...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/snippets/deep_crawl/2.filters.py
docs/snippets/deep_crawl/2.filters.py
import asyncio from typing import List from crawl4ai import ( AsyncWebCrawler, CrawlerRunConfig, BFSDeepCrawlStrategy, CrawlResult, URLFilter, # Base class for filters, not directly used in examples but good to import for context ContentTypeFilter, DomainFilter, FilterChain, URLPatt...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/llm_table_extraction_example.py
docs/examples/llm_table_extraction_example.py
#!/usr/bin/env python3 """ Example demonstrating LLM-based table extraction in Crawl4AI. This example shows how to use the LLMTableExtraction strategy to extract complex tables from web pages, including handling rowspan, colspan, and nested tables. """ import os import sys # Get the grandparent directory grandparent...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/deepcrawl_example.py
docs/examples/deepcrawl_example.py
import asyncio import time from crawl4ai import CrawlerRunConfig, AsyncWebCrawler, CacheMode from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy from crawl4ai.deep_crawling import BFSDeepCrawlStrategy, BestFirstCrawlingStrategy from crawl4ai.deep_crawling.filters import ( FilterChain, URLPat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/llm_markdown_generator.py
docs/examples/llm_markdown_generator.py
import os import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode from crawl4ai import LLMConfig from crawl4ai.content_filter_strategy import LLMContentFilter async def test_llm_filter(): # Create an HTML source that needs intelligent filtering url = "https://docs.python...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/async_webcrawler_multiple_urls_example.py
docs/examples/async_webcrawler_multiple_urls_example.py
# File: async_webcrawler_multiple_urls_example.py import os, sys # append 2 parent directories to sys.path to import crawl4ai parent_dir = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) sys.path.append(parent_dir) import asyncio from crawl4ai import AsyncWebCrawler async def main...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/summarize_page.py
docs/examples/summarize_page.py
import os import json from crawl4ai.web_crawler import WebCrawler from crawl4ai.chunking_strategy import * from crawl4ai import * from crawl4ai.crawler_strategy import * url = r"https://marketplace.visualstudio.com/items?itemName=Unclecode.groqopilot" crawler = WebCrawler() crawler.warmup() from pydantic import Base...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_example.py
docs/examples/docker_example.py
import requests import json import time import sys import base64 import os from typing import Dict, Any class Crawl4AiTester: def __init__(self, base_url: str = "http://localhost:11235"): self.base_url = base_url def submit_and_wait( self, request_data: Dict[str, Any], timeout: int = 300 ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_python_rest_api.py
docs/examples/docker_python_rest_api.py
import asyncio import json from typing import Optional from urllib.parse import quote async def get_token(session, email: str = "test@example.com") -> str: """Fetch a JWT token from the /token endpoint.""" url = "http://localhost:8000/token" payload = {"email": email} print(f"\nFetching token from {url...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/builtin_browser_example.py
docs/examples/builtin_browser_example.py
#!/usr/bin/env python3 """ Builtin Browser Example This example demonstrates how to use Crawl4AI's builtin browser feature, which simplifies the browser management process. With builtin mode: - No need to manually start or connect to a browser - No need to manage CDP URLs or browser processes - Automatically connects...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/dfs_crawl_demo.py
docs/examples/dfs_crawl_demo.py
""" Simple demonstration of the DFS deep crawler visiting multiple pages. Run with: python docs/examples/dfs_crawl_demo.py """ import asyncio from crawl4ai.async_configs import BrowserConfig, CrawlerRunConfig from crawl4ai.async_webcrawler import AsyncWebCrawler from crawl4ai.cache_context import CacheMode from craw...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/identity_based_browsing.py
docs/examples/identity_based_browsing.py
""" Identity-Based Browsing Example with Crawl4AI This example demonstrates how to: 1. Create a persistent browser profile interactively 2. List available profiles 3. Use a saved profile for crawling authenticated sites 4. Delete profiles when no longer needed Uses the new BrowserProfiler class for profile management...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/session_id_example.py
docs/examples/session_id_example.py
import asyncio from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, DefaultMarkdownGenerator, PruningContentFilter, CrawlResult ) async def main(): browser_config = BrowserConfig( headless=False, verbose=True, ) async wit...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_python_sdk.py
docs/examples/docker_python_sdk.py
import asyncio from crawl4ai.docker_client import Crawl4aiDockerClient from crawl4ai import ( BrowserConfig, CrawlerRunConfig ) async def main(): async with Crawl4aiDockerClient(base_url="http://localhost:8000", verbose=True) as client: # If jwt is enabled, authenticate first # await client...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_client_hooks_example.py
docs/examples/docker_client_hooks_example.py
#!/usr/bin/env python3 """ Comprehensive hooks examples using Docker Client with function objects. This approach is recommended because: - Write hooks as regular Python functions - Full IDE support (autocomplete, type checking) - Automatic conversion to API format - Reusable and testable code - Clean, readable syntax ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/quickstart.py
docs/examples/quickstart.py
import os, sys from crawl4ai import LLMConfig sys.path.append( os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ) import asyncio import time import json import re from typing import Dict from bs4 import BeautifulSoup from pydantic import BaseModel, Field from crawl4ai import AsyncWebC...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_webhook_example.py
docs/examples/docker_webhook_example.py
""" Docker Webhook Example for Crawl4AI This example demonstrates how to use webhooks with the Crawl4AI job queue API. Instead of polling for results, webhooks notify your application when jobs complete. Supports both: - /crawl/job - Raw crawling with markdown extraction - /llm/job - LLM-powered content extraction P...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/demo_multi_config_clean.py
docs/examples/demo_multi_config_clean.py
""" 🎯 Multi-Config URL Matching Demo ================================= Learn how to use different crawler configurations for different URL patterns in a single crawl batch with Crawl4AI's multi-config feature. Part 1: Understanding URL Matching (Pattern Testing) Part 2: Practical Example with Real Crawling """ impor...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/browser_optimization_example.py
docs/examples/browser_optimization_example.py
""" This example demonstrates optimal browser usage patterns in Crawl4AI: 1. Sequential crawling with session reuse 2. Parallel crawling with browser instance reuse 3. Performance optimization settings """ import asyncio from typing import List from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig from...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/serp_api_project_11_feb.py
docs/examples/serp_api_project_11_feb.py
import asyncio import json from typing import Any, Dict, List, Optional from regex import P from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, LLMExtractionStrategy, JsonCssExtractionStrategy, CrawlerHub, CrawlResult, DefaultMarkdownGenerator, Pr...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/extraction_strategies_examples.py
docs/examples/extraction_strategies_examples.py
""" Example demonstrating different extraction strategies with various input formats. This example shows how to: 1. Use different input formats (markdown, HTML, fit_markdown) 2. Work with JSON-based extractors (CSS and XPath) 3. Use LLM-based extraction with different input formats 4. Configure browser and crawler sett...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/link_head_extraction_example.py
docs/examples/link_head_extraction_example.py
#!/usr/bin/env python3 """ Link Head Extraction & Scoring Example This example demonstrates Crawl4AI's advanced link analysis capabilities: 1. Basic link head extraction 2. Three-layer scoring system (intrinsic, contextual, total) 3. Pattern-based filtering 4. Multiple practical use cases Requirements: - crawl4ai ins...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/dispatcher_example.py
docs/examples/dispatcher_example.py
import asyncio import time from rich import print from rich.table import Table from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, MemoryAdaptiveDispatcher, SemaphoreDispatcher, RateLimiter, CrawlerMonitor, DisplayMode, CacheMode, LXMLWebScrapingStrategy, ) ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/tutorial_v0.5.py
docs/examples/tutorial_v0.5.py
import asyncio import time import re from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode, BrowserConfig, MemoryAdaptiveDispatcher, HTTPCrawlerConfig from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy from crawl4ai.deep_crawling import ( BestFirstCrawlingStrategy, FilterChain, ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/crawler_monitor_example.py
docs/examples/crawler_monitor_example.py
""" CrawlerMonitor Example This example demonstrates how to use the CrawlerMonitor component to visualize and track web crawler operations in real-time. """ import time import uuid import random import threading from crawl4ai.components.crawler_monitor import CrawlerMonitor from crawl4ai.models import CrawlStatus d...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/regex_extraction_quickstart.py
docs/examples/regex_extraction_quickstart.py
# == File: regex_extraction_quickstart.py == """ Mini–quick-start for RegexExtractionStrategy ──────────────────────────────────────────── 3 bite-sized demos that parallel the style of *quickstart_examples_set_1.py*: 1. **Default catalog** – scrape a page and pull out e-mails / phones / URLs, etc. 2. **Custom patter...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/hello_world.py
docs/examples/hello_world.py
import asyncio from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, DefaultMarkdownGenerator, PruningContentFilter, CrawlResult ) async def main(): browser_config = BrowserConfig( headless=False, verbose=True, ) async with AsyncWebCrawler(config=...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/llm_extraction_openai_pricing.py
docs/examples/llm_extraction_openai_pricing.py
import asyncio from pydantic import BaseModel, Field from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, LLMConfig, BrowserConfig, CacheMode from crawl4ai.extraction_strategy import LLMExtractionStrategy from typing import Dict import os class OpenAIModelFee(BaseModel): model_name: str = Field(..., descriptio...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/rest_call.py
docs/examples/rest_call.py
import requests, base64, os data = { "urls": ["https://www.nbcnews.com/business"], "screenshot": True, } response = requests.post("https://crawl4ai.com/crawl", json=data) result = response.json()["results"][0] print(result.keys()) # dict_keys(['url', 'html', 'success', 'cleaned_html', 'media', # 'links', 'scr...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/ssl_example.py
docs/examples/ssl_example.py
"""Example showing how to work with SSL certificates in Crawl4AI.""" import asyncio import os from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode # Create tmp directory if it doesn't exist parent_dir = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) tmp_dir = os.path.j...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/stealth_test_simple.py
docs/examples/stealth_test_simple.py
""" Simple test to verify stealth mode is working """ import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig async def test_stealth(): """Test stealth mode effectiveness""" # Test WITHOUT stealth print("=== WITHOUT Stealth ===") config1 = BrowserConfig( head...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/undetected_simple_demo.py
docs/examples/undetected_simple_demo.py
""" Simple Undetected Browser Demo Demonstrates the basic usage of undetected browser mode """ import asyncio from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, UndetectedAdapter ) from crawl4ai.async_crawler_strategy import AsyncPlaywrightCrawlerStrategy async def crawl_with_r...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/quickstart_examples_set_1.py
docs/examples/quickstart_examples_set_1.py
import asyncio import os import json import base64 from pathlib import Path from typing import List from crawl4ai import ProxyConfig from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode, CrawlResult from crawl4ai import RoundRobinProxyStrategy from crawl4ai import JsonCssExtractionStrategy, LLMExtractionS...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/scraping_strategies_performance.py
docs/examples/scraping_strategies_performance.py
import time, re from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy # WebScrapingStrategy is now an alias for LXMLWebScrapingStrategy import time import functools from collections import defaultdict class TimingStats: def __init__(self): self.stats = defaultdict(lambda: defaultdict(lambd...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/quickstart_examples_set_2.py
docs/examples/quickstart_examples_set_2.py
import os, sys from crawl4ai.types import LLMConfig sys.path.append( os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ) import asyncio import time import json import re from typing import Dict from bs4 import BeautifulSoup from pydantic import BaseModel, Field from crawl4ai import Asy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/simple_anti_bot_examples.py
docs/examples/simple_anti_bot_examples.py
import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, UndetectedAdapter from crawl4ai.async_crawler_strategy import AsyncPlaywrightCrawlerStrategy # Example 1: Stealth Mode async def stealth_mode_example(): browser_config = BrowserConfig( enable_stealth=True, headles...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/virtual_scroll_example.py
docs/examples/virtual_scroll_example.py
""" Example of using the virtual scroll feature to capture content from pages with virtualized scrolling (like Twitter, Instagram, or other infinite scroll feeds). This example demonstrates virtual scroll with a local test server serving different types of scrolling behaviors from HTML files in the assets directory. "...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/table_extraction_example.py
docs/examples/table_extraction_example.py
""" Example: Using Table Extraction Strategies in Crawl4AI This example demonstrates how to use different table extraction strategies to extract tables from web pages. """ import asyncio import pandas as pd from crawl4ai import ( AsyncWebCrawler, CrawlerRunConfig, CacheMode, DefaultTableExtraction, ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_config_obj.py
docs/examples/docker_config_obj.py
from crawl4ai import BrowserConfig, CrawlerRunConfig, PruningContentFilter, DefaultMarkdownGenerator from crawl4ai.deep_crawling.filters import ContentTypeFilter, DomainFilter from crawl4ai.deep_crawling.scorers import KeywordRelevanceScorer, PathDepthScorer from crawl4ai.cache_context import CacheMode from crawl4ai.de...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/amazon_product_extraction_using_hooks.py
docs/examples/amazon_product_extraction_using_hooks.py
""" This example demonstrates how to use JSON CSS extraction to scrape product information from Amazon search results. It shows how to extract structured data like product titles, prices, ratings, and other details using CSS selectors. """ from crawl4ai import AsyncWebCrawler, CacheMode from crawl4ai import JsonCssEx...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/docker_hooks_examples.py
docs/examples/docker_hooks_examples.py
#!/usr/bin/env python3 """ πŸš€ Crawl4AI Docker Hooks System - Complete Examples ==================================================== This file demonstrates the Docker Hooks System with three different approaches: 1. String-based hooks for REST API 2. hooks_to_string() utility to convert functions 3. Docker Client with...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/research_assistant.py
docs/examples/research_assistant.py
# Make sure to install the required packageschainlit and groq import os, time from openai import AsyncOpenAI import chainlit as cl import re import requests from io import BytesIO from chainlit.element import ElementBased from groq import Groq # Import threadpools to run the crawl_url function in a separate thread fro...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/stealth_mode_quick_start.py
docs/examples/stealth_mode_quick_start.py
""" Quick Start: Using Stealth Mode in Crawl4AI This example shows practical use cases for the stealth mode feature. Stealth mode helps bypass basic bot detection mechanisms. """ import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig async def example_1_basic_stealth(): """Example ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/network_console_capture_example.py
docs/examples/network_console_capture_example.py
import asyncio import json import os import base64 from pathlib import Path from typing import List, Dict, Any from datetime import datetime from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode, CrawlResult from crawl4ai import BrowserConfig __cur_dir__ = Path(__file__).parent # Create temp directory if...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/proxy_rotation_demo.py
docs/examples/proxy_rotation_demo.py
import os import re from typing import List, Dict from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, RoundRobinProxyStrategy ) def load_proxies_from_env() -> List[Dict]: """Load proxies from PROXIES environment variable""" proxies = [] try: proxy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/amazon_product_extraction_direct_url.py
docs/examples/amazon_product_extraction_direct_url.py
""" This example demonstrates how to use JSON CSS extraction to scrape product information from Amazon search results. It shows how to extract structured data like product titles, prices, ratings, and other details using CSS selectors. """ from crawl4ai import AsyncWebCrawler from crawl4ai import JsonCssExtractionStr...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/docs/examples/hello_world_undetected.py
docs/examples/hello_world_undetected.py
import asyncio from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, DefaultMarkdownGenerator, PruningContentFilter, CrawlResult, UndetectedAdapter ) from crawl4ai.async_crawler_strategy import AsyncPlaywrightCrawlerStrategy async def main(): # Create browser config ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false