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/tests/memory/test_stress_api.py
tests/memory/test_stress_api.py
#!/usr/bin/env python3 """ Stress test for Crawl4AI's Docker API server (/crawl and /crawl/stream endpoints). This version targets a running Crawl4AI API server, sending concurrent requests to test its ability to handle multiple crawl jobs simultaneously. It uses httpx for async HTTP requests and logs results per batc...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/run_benchmark.py
tests/memory/run_benchmark.py
#!/usr/bin/env python3 """ Run a complete Crawl4AI benchmark test using test_stress_sdk.py and generate a report. """ import sys import os import glob import argparse import subprocess import time from datetime import datetime from rich.console import Console from rich.text import Text console = Console() # Updated...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_stress_api_xs.py
tests/memory/test_stress_api_xs.py
"""Lite Crawl4AI API stress‑tester. ✔ batch or stream mode (single unified path) ✔ global stats + JSON summary ✔ rich table progress ✔ Typer CLI with presets (quick / soak) Usage examples: python api_stress_test.py # uses quick preset python api_stress_test.py soak # 5 K URLs stress run...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_dispatcher_stress.py
tests/memory/test_dispatcher_stress.py
import asyncio import time import psutil import logging import random from typing import List, Dict import uuid import sys import os # Import your crawler components from crawl4ai.models import DisplayMode, CrawlStatus, CrawlResult from crawl4ai.async_configs import CrawlerRunConfig, BrowserConfig, CacheMode from craw...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_docker_config_gen.py
tests/memory/test_docker_config_gen.py
#!/usr/bin/env python3 """ Quick sanity‑check for /config/dump endpoint. Usage: python test_config_dump.py [http://localhost:8020] If the server isn’t running, start it first: uvicorn deploy.docker.server:app --port 8020 """ import sys, json, textwrap, requests # BASE = sys.argv[1] if len(sys.argv) > 1 els...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/cap_test.py
tests/memory/cap_test.py
#!/usr/bin/env python3 """ Hammer /crawl with many concurrent requests to prove GLOBAL_SEM works. """ import asyncio, httpx, json, uuid, argparse API = "http://localhost:8020/crawl" URLS_PER_CALL = 1 # keep it minimal so each arun() == 1 page CONCURRENT_CALLS = 20 # way above your cap payload_template ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_stress_docker_api.py
tests/memory/test_stress_docker_api.py
""" Crawl4AI Docker API stress tester. Examples -------- python test_stress_docker_api.py --urls 1000 --concurrency 32 python test_stress_docker_api.py --urls 1000 --concurrency 32 --stream python test_stress_docker_api.py --base-url http://10.0.0.42:11235 --http2 """ import argparse, asyncio, json, secrets, statisti...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_stress_sdk.py
tests/memory/test_stress_sdk.py
#!/usr/bin/env python3 """ Stress test for Crawl4AI's arun_many and dispatcher system. This version uses a local HTTP server and focuses on testing the SDK's ability to handle multiple URLs concurrently, with per-batch logging. """ import asyncio import os import time import pathlib import random import secrets import...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_parameters_and_options.py
tests/async/test_parameters_and_options.py
import os import sys import pytest # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_word_count_threshold(): async with Async...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_caching.py
tests/async/test_caching.py
import os import sys import pytest import asyncio # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_caching(): async with Asy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_edge_cases.py
tests/async/test_edge_cases.py
import os import re import sys import pytest from bs4 import BeautifulSoup import asyncio # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler # @pytest.mark.asyncio # a...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_crawler_strategy.py
tests/async/test_crawler_strategy.py
import os import sys import pytest # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_custom_user_agent(): async with AsyncWeb...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_async_doanloader.py
tests/async/test_async_doanloader.py
import os import sys import asyncio import shutil from typing import List import tempfile # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler class TestDownloads: ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_content_filter_prune.py
tests/async/test_content_filter_prune.py
import os, sys import pytest parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.content_filter_strategy import PruningContentFilter @pytest.fixture def basic_html(): return """ <html> <body> <article> <h1>Mai...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_content_extraction.py
tests/async/test_content_extraction.py
import os import sys import pytest # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_extract_markdown(): async with AsyncWebC...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_evaluation_scraping_methods_performance.configs.py
tests/async/test_evaluation_scraping_methods_performance.configs.py
import json import time from bs4 import BeautifulSoup from crawl4ai.content_scraping_strategy import ( WebScrapingStrategy, LXMLWebScrapingStrategy, ) from typing import Dict, List, Tuple import difflib from lxml import html as lhtml, etree def normalize_dom(element): """ Recursively normalizes an lxm...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_content_scraper_strategy.py
tests/async/test_content_scraper_strategy.py
import os import sys import time import csv from tabulate import tabulate from dataclasses import dataclass from typing import List parent_dir = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) sys.path.append(parent_dir) __location__ = os.path.realpath(os.path.join(os.getcwd(), os.pa...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_dispatchers.py
tests/async/test_dispatchers.py
import pytest import time from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, MemoryAdaptiveDispatcher, SemaphoreDispatcher, RateLimiter, CrawlerMonitor, DisplayMode, CacheMode, ) @pytest.fixture def browser_config(): return BrowserConfig(headless=True, ver...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_markdown_genertor.py
tests/async/test_markdown_genertor.py
# ## Issue #236 # - **Last Updated:** 2024-11-11 01:42:14 # - **Title:** [user data crawling opens two windows, unable to control correct user browser](https://github.com/unclecode/crawl4ai/issues/236) # - **State:** open import os, sys, time parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_basic_crawling.py
tests/async/test_basic_crawling.py
import os import sys import pytest import time # Add the parent directory to the Python path parent_dir = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_successfu...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_chunking_and_extraction_strategies.py
tests/async/test_chunking_and_extraction_strategies.py
import os import sys import pytest import json # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai import LLMConfig from crawl4ai.async_webcrawler import AsyncWebCrawler from crawl4ai.chunking_strategy import ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_content_filter_bm25.py
tests/async/test_content_filter_bm25.py
import os, sys import pytest from bs4 import BeautifulSoup # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.content_filter_strategy import BM25ContentFilter @pytest.fixture def basic_html(): return ""...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_screenshot.py
tests/async/test_screenshot.py
import os import sys import pytest import base64 from PIL import Image import io # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def tes...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_error_handling.py
tests/async/test_error_handling.py
# import os # import sys # import pytest # import asyncio # # Add the parent directory to the Python path # parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # sys.path.append(parent_dir) # from crawl4ai.async_webcrawler import AsyncWebCrawler # from crawl4ai.utils import InvalidCSSSelectorErro...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_performance.py
tests/async/test_performance.py
import os import sys import pytest import time # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_crawl_speed(): async with As...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_0.4.2_browser_manager.py
tests/async/test_0.4.2_browser_manager.py
import os import sys import asyncio from crawl4ai import AsyncWebCrawler, CacheMode from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) __location__ = os.path.realpath(os.path.join(os.getcwd(), o...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_database_operations.py
tests/async/test_database_operations.py
import os import sys import pytest # Add the parent directory to the Python path parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) from crawl4ai.async_webcrawler import AsyncWebCrawler @pytest.mark.asyncio async def test_cache_url(): async with AsyncWebCrawler(...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_redirect_url_resolution.py
tests/async/test_redirect_url_resolution.py
"""Test delayed redirect WITH wait_for - does link resolution use correct URL?""" import asyncio import threading from http.server import HTTPServer, SimpleHTTPRequestHandler class RedirectTestHandler(SimpleHTTPRequestHandler): def log_message(self, format, *args): pass def do_GET(self): if se...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async/test_0.4.2_config_params.py
tests/async/test_0.4.2_config_params.py
import os, sys parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) import asyncio from crawl4ai import AsyncWebCrawler, CacheMode from crawl4ai.async_configs import BrowserConfig, Cra...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_url_pattern.py
tests/general/test_url_pattern.py
import sys import os # Get the grandparent directory grandparent_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(grandparent_dir) __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) import asyncio from crawl4ai.deep_crawling.filters ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_async_markdown_generator.py
tests/general/test_async_markdown_generator.py
import asyncio from typing import Dict from crawl4ai.content_filter_strategy import BM25ContentFilter, PruningContentFilter from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator import time # Test HTML samples TEST_HTML_SAMPLES = { "basic": """ <body> <h1>Test Title</h1> ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_crawlers.py
tests/general/test_crawlers.py
# example_usageexample_usageexample_usage# example_usage.py import asyncio from crawl4ai.crawlers import get_crawler async def main(): # Get the registered crawler example_crawler = get_crawler("example_site.content") # Crawl example.com result = await example_crawler(url="https://example.com") ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_deep_crawl_scorers.py
tests/general/test_deep_crawl_scorers.py
from crawl4ai.deep_crawling.scorers import CompositeScorer, ContentTypeScorer, DomainAuthorityScorer, FreshnessScorer, KeywordRelevanceScorer, PathDepthScorer def test_scorers(): test_cases = [ # Keyword Scorer Tests { "scorer_type": "keyword", "config": { "...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/tets_robot.py
tests/general/tets_robot.py
import asyncio from crawl4ai import * async def test_real_websites(): print("\n=== Testing Real Website Robots.txt Compliance ===\n") browser_config = BrowserConfig(headless=True, verbose=True) async with AsyncWebCrawler(config=browser_config) as crawler: # Test cases with URLs ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_content_source_parameter.py
tests/general/test_content_source_parameter.py
""" Tests for the content_source parameter in markdown generation. """ import unittest import asyncio from unittest.mock import patch, MagicMock from crawl4ai.markdown_generation_strategy import DefaultMarkdownGenerator, MarkdownGenerationStrategy from crawl4ai.async_webcrawler import AsyncWebCrawler from crawl4ai.asy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_advanced_deep_crawl.py
tests/general/test_advanced_deep_crawl.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, URLPatternFilte...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_schema_builder.py
tests/general/test_schema_builder.py
# https://claude.ai/chat/c4bbe93d-fb54-44ce-92af-76b4c8086c6b # https://claude.ai/chat/c24a768c-d8b2-478a-acc7-d76d42a308da import os, sys parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__fil...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/generate_dummy_site.py
tests/general/generate_dummy_site.py
# ==== File: build_dummy_site.py ==== import os import random import argparse from pathlib import Path from urllib.parse import quote # --- Configuration --- NUM_CATEGORIES = 3 NUM_SUBCATEGORIES_PER_CAT = 2 # Results in NUM_CATEGORIES * NUM_SUBCATEGORIES_PER_CAT total L2 categories NUM_PRODUCTS_PER_SUBCAT = 5 # Produ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_deep_crawl.py
tests/general/test_deep_crawl.py
import asyncio import time from crawl4ai import CrawlerRunConfig, AsyncWebCrawler, CacheMode from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy from crawl4ai.deep_crawling import BFSDeepCrawlStrategy # from crawl4ai.deep_crawling import BFSDeepCrawlStrategy, BestFirstCrawlingStrategy async def m...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_deep_crawl_filters.py
tests/general/test_deep_crawl_filters.py
from crawl4ai.deep_crawling.filters import ContentRelevanceFilter, URLPatternFilter, DomainFilter, ContentTypeFilter, SEOFilter async def test_pattern_filter(): # Test cases as list of tuples instead of dict for multiple patterns test_cases = [ # Simple suffix patterns (*.html) ("*.html", { ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_llm_filter.py
tests/general/test_llm_filter.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/tests/general/test_network_console_capture.py
tests/general/test_network_console_capture.py
from crawl4ai.async_webcrawler import AsyncWebCrawler from crawl4ai.async_configs import CrawlerRunConfig, BrowserConfig import asyncio import aiohttp from aiohttp import web import tempfile import shutil import os, sys, time, json async def start_test_server(): app = web.Application() async def basic_pa...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_async_webcrawler.py
tests/general/test_async_webcrawler.py
import asyncio import pytest from typing import List from crawl4ai import ( AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, MemoryAdaptiveDispatcher, RateLimiter, CacheMode ) from crawl4ai.extraction_strategy import ExtractionStrategy class MockExtractionStrategy(ExtractionStrategy): """...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_bff_scoring.py
tests/general/test_bff_scoring.py
#!/usr/bin/env python3 """ Simple test to verify BestFirstCrawlingStrategy fixes. This test crawls a real website and shows that: 1. Higher-scoring pages are crawled first (priority queue fix) 2. Links are scored before truncation (link discovery fix) """ import asyncio from crawl4ai import AsyncWebCrawler, BrowserCon...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_stream_dispatch.py
tests/general/test_stream_dispatch.py
import os, sys # append 2 parent directories to sys.path to import crawl4ai parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) parent_parent_dir = os.path.dirname(parent_dir) sys.path.append(parent_parent_dir) import asyncio from typing import List from crawl4ai impor...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_acyn_crawl_wuth_http_crawler_strategy.py
tests/general/test_acyn_crawl_wuth_http_crawler_strategy.py
import asyncio from crawl4ai import ( AsyncWebCrawler, CrawlerRunConfig, HTTPCrawlerConfig, CacheMode, DefaultMarkdownGenerator, PruningContentFilter ) from crawl4ai.async_crawler_strategy import AsyncHTTPCrawlerStrategy from crawl4ai.async_logger import AsyncLogger async def main(): # Init...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_persistent_context.py
tests/general/test_persistent_context.py
import asyncio import os from crawl4ai.async_webcrawler import AsyncWebCrawler from crawl4ai.async_configs import BrowserConfig, CrawlerRunConfig, CacheMode # Simple concurrency test for persistent context page creation # Usage: python scripts/test_persistent_context.py URLS = [ # "https://example.com", "http...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_robot_parser.py
tests/general/test_robot_parser.py
from crawl4ai.utils import RobotsParser import asyncio import aiohttp from aiohttp import web import tempfile import shutil import os, sys, time, json async def test_robots_parser(): print("\n=== Testing RobotsParser ===\n") # Setup temporary directory for testing temp_dir = tempfile.mkd...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_max_scroll.py
tests/general/test_max_scroll.py
""" Sample script to test the max_scroll_steps parameter implementation """ import asyncio import os import sys # Get the grandparent directory grandparent_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(grandparent_dir) __location__ = os.path.realpath(os.path.join(os...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_async_url_seeder_bm25.py
tests/general/test_async_url_seeder_bm25.py
""" Comprehensive test cases for AsyncUrlSeeder with BM25 scoring functionality. Tests cover all features including query-based scoring, metadata extraction, edge cases, and integration scenarios. """ import asyncio import pytest from typing import List, Dict, Any from crawl4ai import AsyncUrlSeeder, SeedingConfig, A...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_download_file.py
tests/general/test_download_file.py
import asyncio from crawl4ai import CrawlerRunConfig, AsyncWebCrawler, BrowserConfig from pathlib import Path import os async def test_basic_download(): # Custom folder (otherwise defaults to ~/.crawl4ai/downloads) downloads_path = os.path.join(Path.home(), ".crawl4ai", "downloads") os.makedirs(downlo...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_mhtml.py
tests/general/test_mhtml.py
# test_mhtml_capture.py import pytest import asyncio import re # For more robust MHTML checks # Assuming these can be imported directly from the crawl4ai library from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CrawlResult # A reliable, simple static HTML page for testing # Using httpbin as it...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_cache_context.py
tests/general/test_cache_context.py
import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode from playwright.async_api import Page, BrowserContext async def test_reuse_context_by_config(): # We will store each context ID in these maps to confirm reuse context_ids_for_A = [] context_ids_for_B = [] #...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_stream.py
tests/general/test_stream.py
import os, sys # append 2 parent directories to sys.path to import crawl4ai parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(parent_dir) parent_parent_dir = os.path.dirname(parent_dir) sys.path.append(parent_parent_dir) import asyncio from crawl4ai import * async def test_crawl...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_http_crawler_strategy.py
tests/general/test_http_crawler_strategy.py
from tkinter import N from crawl4ai.async_crawler_strategy import AsyncHTTPCrawlerStrategy from crawl4ai.async_logger import AsyncLogger from crawl4ai import CrawlerRunConfig, HTTPCrawlerConfig from crawl4ai.async_crawler_strategy import ConnectionTimeoutError import asyncio import os async def main(): """Test the...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/general/test_async_crawler_strategy.py
tests/general/test_async_crawler_strategy.py
import pytest import pytest_asyncio import asyncio from typing import Dict, Any from pathlib import Path from unittest.mock import MagicMock, patch import os from crawl4ai.async_configs import BrowserConfig, CrawlerRunConfig from crawl4ai.async_crawler_strategy import AsyncPlaywrightCrawlerStrategy from crawl4ai.models...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/hub/test_simple.py
tests/hub/test_simple.py
# test.py from crawl4ai import CrawlerHub import json async def amazon_example(): if (crawler_cls := CrawlerHub.get("amazon_product")) : crawler = crawler_cls() print(f"Crawler version: {crawler_cls.meta['version']}") print(f"Rate limits: {crawler_cls.meta.get('rate_limit', 'Unlimited')}") ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/deep_crwaling/test_filter.py
tests/deep_crwaling/test_filter.py
# // File: tests/deep_crawling/test_filters.py import pytest from urllib.parse import urlparse from crawl4ai import ContentTypeFilter, URLFilter # Minimal URLFilter base class stub if not already importable directly for tests # In a real scenario, this would be imported from the library if not hasattr(URLFilter, '_up...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/unit/test_sitemap_namespace_parsing.py
tests/unit/test_sitemap_namespace_parsing.py
import sys from types import SimpleNamespace import pytest # Provide a lightweight stub for rank_bm25 before importing the seeder to avoid # optional dependency issues (e.g., incompatible wheels in CI). class _FakeBM25: def __init__(self, corpus): self._scores = [1.0] * len(corpus) def get_scores(sel...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/cli/test_cli.py
tests/cli/test_cli.py
import pytest from click.testing import CliRunner from pathlib import Path import json import yaml from crawl4ai.cli import cli, load_config_file, parse_key_values import tempfile import os import click @pytest.fixture def runner(): return CliRunner() @pytest.fixture def temp_config_dir(): with tempfile.Tempo...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/releases/test_release_0.6.4.py
tests/releases/test_release_0.6.4.py
import pytest import asyncio import time from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, BrowserConfig, CacheMode @pytest.mark.asyncio async def test_wait_for_timeout_separate_from_page_timeout(): """Test that wait_for has its own timeout separate from page_timeout""" browser_config = BrowserConfig(he...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/releases/test_release_0.7.0.py
tests/releases/test_release_0.7.0.py
#!/usr/bin/env python3 import asyncio import pytest import os import json import tempfile from pathlib import Path from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode from crawl4ai import JsonCssExtractionStrategy, LLMExtractionStrategy, LLMConfig from crawl4ai.content_filter_strategy impo...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_cdp_strategy.py
tests/browser/test_cdp_strategy.py
"""Test examples for CDPBrowserStrategy. These examples demonstrate the functionality of CDPBrowserStrategy and serve as functional tests. """ import asyncio import os import sys import time # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.insert(0, os.path.abspath(os...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_builtin_strategy.py
tests/browser/test_builtin_strategy.py
"""Test examples for BuiltinBrowserStrategy. These examples demonstrate the functionality of BuiltinBrowserStrategy and serve as functional tests. """ import asyncio import os import sys # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.insert(0, os.path.abspath(os.pat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_playwright_strategy.py
tests/browser/test_playwright_strategy.py
"""Test examples for PlaywrightBrowserStrategy. These examples demonstrate the functionality of PlaywrightBrowserStrategy and serve as functional tests. """ import asyncio import os import re import sys # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.insert(0, os.pat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_combined.py
tests/browser/test_combined.py
"""Combined test runner for all browser module tests. This script runs all the browser module tests in sequence and provides a comprehensive summary. """ import asyncio import os import sys import time # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.insert(0, os.path...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_builtin_browser.py
tests/browser/test_builtin_browser.py
""" Test script for builtin browser functionality in the browser module. This script tests: 1. Creating a builtin browser 2. Getting browser information 3. Killing the browser 4. Restarting the browser 5. Testing operations with different browser strategies 6. Testing edge cases """ import asyncio import os import sy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_parallel_crawling.py
tests/browser/test_parallel_crawling.py
""" Test examples for parallel crawling with the browser module. These examples demonstrate the functionality of parallel page creation and serve as functional tests for multi-page crawling performance. """ import asyncio import os import sys import time from typing import List # Add the project root to Python path ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_browser_manager.py
tests/browser/test_browser_manager.py
"""Test examples for BrowserManager. These examples demonstrate the functionality of BrowserManager and serve as functional tests. """ import asyncio import os import sys from typing import List # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.insert(0, os.path.abspat...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_profiles.py
tests/browser/test_profiles.py
"""Test examples for BrowserProfileManager. These examples demonstrate the functionality of BrowserProfileManager and serve as functional tests. """ import asyncio import os import sys import uuid import shutil from crawl4ai import BrowserProfiler from crawl4ai.browser_manager import BrowserManager # Add the projec...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/test_launch_standalone.py
tests/browser/test_launch_standalone.py
from crawl4ai.browser_profiler import BrowserProfiler import asyncio if __name__ == "__main__": # Test launching a standalone browser async def test_standalone_browser(): profiler = BrowserProfiler() cdp_url = await profiler.launch_standalone_browser( browser_type="chromium", ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/docker/__init__.py
tests/browser/docker/__init__.py
"""Docker browser strategy tests. This package contains tests for the Docker browser strategy implementation. """
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/docker/test_docker_browser.py
tests/browser/docker/test_docker_browser.py
"""Test examples for Docker Browser Strategy. These examples demonstrate the functionality of Docker Browser Strategy and serve as functional tests. """ import asyncio import os import sys import shutil import uuid # Add the project root to Python path if running directly if __name__ == "__main__": sys.path.inse...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/browser/manager/demo_browser_manager.py
tests/browser/manager/demo_browser_manager.py
"""Demo script for testing the enhanced BrowserManager. This script demonstrates the browser pooling capabilities of the enhanced BrowserManager with various configurations and usage patterns. """ import asyncio import time import random from crawl4ai.browser.manager import BrowserManager, UnavailableBehavior from c...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/mcp/test_mcp_socket.py
tests/mcp/test_mcp_socket.py
# pip install "mcp-sdk[ws]" anyio import anyio, json from mcp.client.websocket import websocket_client from mcp.client.session import ClientSession async def test_list(): async with websocket_client("ws://localhost:8020/mcp/ws") as (r, w): async with ClientSession(r, w) as s: await s.initialize...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/mcp/test_mcp_sse.py
tests/mcp/test_mcp_sse.py
from mcp.client.sse import sse_client from mcp.client.session import ClientSession async def main(): async with sse_client("http://127.0.0.1:8020/mcp") as (r, w): async with ClientSession(r, w) as sess: print(await sess.list_tools()) # now works if __name__ == "__main__": ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/loggers/test_logger.py
tests/loggers/test_logger.py
import asyncio from crawl4ai import AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode, AsyncLoggerBase import os from datetime import datetime class AsyncFileLogger(AsyncLoggerBase): """ File-only asynchronous logger that writes logs to a specified file. """ def __init__(self, log_file: str)...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/docker_client.py
crawl4ai/docker_client.py
from typing import List, Optional, Union, AsyncGenerator, Dict, Any, Callable import httpx import json from urllib.parse import urljoin import asyncio from .async_configs import BrowserConfig, CrawlerRunConfig from .models import CrawlResult from .async_logger import AsyncLogger, LogLevel from .utils import hooks_to_s...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/prompts.py
crawl4ai/prompts.py
PROMPT_EXTRACT_BLOCKS = """Here is the URL of the webpage: <url>{URL}</url> And here is the cleaned HTML content of that webpage: <html> {HTML} </html> Your task is to break down this HTML content into semantically relevant blocks, and for each block, generate a JSON object with the following keys: - index: an integ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_crawler_strategy.back.py
crawl4ai/async_crawler_strategy.back.py
from __future__ import annotations import asyncio import base64 import time from abc import ABC, abstractmethod from typing import Callable, Dict, Any, List, Union from typing import Optional, AsyncGenerator, Final import os from playwright.async_api import Page, Error from playwright.async_api import TimeoutError as ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_dispatcher.py
crawl4ai/async_dispatcher.py
from typing import Dict, Optional, List, Tuple, Union from .async_configs import CrawlerRunConfig from .models import ( CrawlResult, CrawlerTaskResult, CrawlStatus, DomainState, ) from .components.crawler_monitor import CrawlerMonitor from .types import AsyncWebCrawler from collections.abc import Asy...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/cli.py
crawl4ai/cli.py
import click import os import sys import time import humanize from typing import Dict, Any, Optional, List import json import yaml import anyio from rich.console import Console from rich.table import Table from rich.panel import Panel from rich.prompt import Prompt, Confirm from crawl4ai import ( CacheMode, A...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_logger.py
crawl4ai/async_logger.py
from abc import ABC, abstractmethod from enum import Enum from typing import Optional, Dict, Any, List import os from datetime import datetime from urllib.parse import unquote from rich.console import Console from rich.text import Text from .utils import create_box_message class LogLevel(Enum): DEFAULT = 0 DE...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/models.py
crawl4ai/models.py
from pydantic import BaseModel, HttpUrl, PrivateAttr, Field, ConfigDict from typing import List, Dict, Optional, Callable, Awaitable, Union, Any from typing import AsyncGenerator from typing import Generic, TypeVar from enum import Enum from dataclasses import dataclass from .ssl_certificate import SSLCertificate from ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_database.py
crawl4ai/async_database.py
import os from pathlib import Path import aiosqlite import asyncio from typing import Optional, Dict from contextlib import asynccontextmanager import json from .models import CrawlResult, MarkdownGenerationResult, StringCompatibleMarkdown import aiofiles from .async_logger import AsyncLogger from .utils import ensu...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/ssl_certificate.py
crawl4ai/ssl_certificate.py
"""SSL Certificate class for handling certificate operations.""" import ssl import socket import base64 import json from typing import Dict, Any, Optional from urllib.parse import urlparse import OpenSSL.crypto from pathlib import Path # === Inherit from dict === class SSLCertificate(dict): """ A class repres...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/chunking_strategy.py
crawl4ai/chunking_strategy.py
from abc import ABC, abstractmethod import re from collections import Counter import string from .model_loader import load_nltk_punkt # Define the abstract base class for chunking strategies class ChunkingStrategy(ABC): """ Abstract base class for chunking strategies. """ @abstractmethod def chunk...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/browser_manager.py
crawl4ai/browser_manager.py
import asyncio import time from typing import List, Optional import os import sys import shutil import tempfile import psutil import signal import subprocess import shlex from playwright.async_api import BrowserContext import hashlib from .js_snippet import load_js_script from .config import DOWNLOAD_PAGE_TIMEOUT fro...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_webcrawler.py
crawl4ai/async_webcrawler.py
from .__version__ import __version__ as crawl4ai_version import os import sys import time from pathlib import Path from typing import Optional, List import json import asyncio # from contextlib import nullcontext, asynccontextmanager from contextlib import asynccontextmanager from .models import ( CrawlResult, ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/migrations.py
crawl4ai/migrations.py
import os import asyncio from pathlib import Path import aiosqlite from typing import Optional import xxhash import aiofiles import shutil from datetime import datetime from .async_logger import AsyncLogger, LogLevel # Initialize logger logger = AsyncLogger(log_level=LogLevel.DEBUG, verbose=True) # logging.basicConfi...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/model_loader.py
crawl4ai/model_loader.py
from functools import lru_cache from pathlib import Path import subprocess, os import shutil from .model_loader import * import argparse from crawl4ai.config import MODEL_REPO_BRANCH __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) @lru_cache() def get_available_memory(device): ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/table_extraction.py
crawl4ai/table_extraction.py
""" Table extraction strategies for Crawl4AI. This module provides various strategies for detecting and extracting tables from HTML content. The strategy pattern allows for flexible table extraction methods while maintaining a consistent interface. """ from abc import ABC, abstractmethod from typing import Dict, List...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/utils.py
crawl4ai/utils.py
import time from concurrent.futures import ThreadPoolExecutor, as_completed from bs4 import BeautifulSoup, Comment, element, Tag, NavigableString import json import html import lxml import re import os import subprocess import platform from .prompts import PROMPT_EXTRACT_BLOCKS from array import array from .html2text i...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/content_scraping_strategy.py
crawl4ai/content_scraping_strategy.py
import re from itertools import chain from abc import ABC, abstractmethod from typing import Dict, Any, Optional from bs4 import BeautifulSoup import asyncio import requests from .config import ( MIN_WORD_THRESHOLD, IMAGE_DESCRIPTION_MIN_WORD_THRESHOLD, IMAGE_SCORE_THRESHOLD, ONLY_TEXT_ELIGIBLE_TAGS, ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/async_crawler_strategy.py
crawl4ai/async_crawler_strategy.py
from __future__ import annotations import asyncio import base64 import time from abc import ABC, abstractmethod from typing import Callable, Dict, Any, List, Union from typing import Optional, AsyncGenerator, Final import os from playwright.async_api import Page, Error from playwright.async_api import TimeoutError as ...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/user_agent_generator.py
crawl4ai/user_agent_generator.py
import random from typing import Optional, Literal, List, Dict, Tuple import re from abc import ABC, abstractmethod from fake_useragent import UserAgent import requests from lxml import html import json from typing import Union class UAGen(ABC): @abstractmethod def generate(self, browsers: Optio...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
false
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/adaptive_crawler copy.py
crawl4ai/adaptive_crawler copy.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/async_configs.py
crawl4ai/async_configs.py
import importlib import os import warnings import requests from .config import ( DEFAULT_PROVIDER, DEFAULT_PROVIDER_API_KEY, MIN_WORD_THRESHOLD, IMAGE_DESCRIPTION_MIN_WORD_THRESHOLD, PROVIDER_MODELS, PROVIDER_MODELS_PREFIXES, SCREENSHOT_HEIGHT_TRESHOLD, PAGE_TIMEOUT, IMAGE_SCORE_THRE...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/content_filter_strategy.py
crawl4ai/content_filter_strategy.py
import inspect import re import time from bs4 import BeautifulSoup, Tag from typing import List, Tuple, Dict, Optional from rank_bm25 import BM25Okapi from collections import deque from bs4 import NavigableString, Comment from .utils import ( clean_tokens, perform_completion_with_backoff, escape_json_strin...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true
unclecode/crawl4ai
https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/crawl4ai/browser_profiler.py
crawl4ai/browser_profiler.py
""" Browser Profiler Module This module provides a dedicated class for managing browser profiles that can be used for identity-based crawling with Crawl4AI. """ import os import asyncio import signal import sys import datetime import uuid import shutil import json import subprocess import time from typing import List...
python
Apache-2.0
c85f56b085a1d5b62779774d48887345e566869b
2026-01-04T14:38:51.943025Z
true