Strategy pattern implementation for detecting and extracting HTML tables, supporting default, none, and LLM‑based methods.
# Source: https://github.com/mperkins0155/crawl4ai-cobaltai | License: Apache-2.0
# Provided via justclaw.it.com; keep this notice with the code.
"""
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, Optional, Any, Union, Tuple
from lxml import etree
import re
import json
from .types import LLMConfig, create_llm_config
from .utils import perform_completion_with_backoff, sanitize_html
import os
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
import tiktoken
class TableExtractionStrategy(ABC):
"
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key