Automated keyword extraction and visual highlighting from SEC EDGAR HTML filings
SEC HTML Data Miner is a specialized data extraction and visualization tool for SEC EDGAR filings. It automatically:
- 📊 Loads keyword data from Parquet files (financial indicators, executive names, stock transactions)
- 🔍 Matches keywords in HTML filings using smart fuzzy/strict matching strategies
- 🎨 Highlights results directly in HTML for easy visualization
- ⚡ Processes at scale with support for batch processing and ZIP archives
Perfect for:
- Financial research and due diligence automation
- Extracting officer/insider trading information from Form 4 filings
- Automating SEC document analysis workflows
- Building financial data pipelines
# Clone repository
git clone https://github.com/Alex-Wang66/SEC-HTML-Data-Miner.git
cd SEC-HTML-Data-Miner
# Install dependencies
pip install -r requirements.txt
# Install as package
pip install -e .# Process a directory of HTML filings
python -m src.cli \
--parquet-dir ./data/keywords_parquet \
--html-dir ./data/sec_filings \
--output-dir ./output_highlighted
# With custom highlight color and debug mode
python -m src.cli \
--parquet-dir ./data/keywords_parquet \
--html-dir ./data/sec_filings \
--output-dir ./output \
--color lime \
--debugfrom src.pipeline import SECDataMiningPipeline
pipeline = SECDataMiningPipeline(
parquet_dir='./data/keywords',
html_dir='./data/filings',
output_dir='./output',
highlight_color='yellow',
debug_border=False,
match_strategy='smart'
)
stats = pipeline.run()
print(f"Processed {stats['processed']} files, found {stats['matched']} matches")Parser (parser.py)
ParquetReader: Loads keyword data indexed by SEC Accession IDHTMLParser: Parses SEC EDGAR HTML files while preserving DOM structureAccessionIDExtractor: Extracts SEC identifiers from filenames
Matcher (matcher.py)
StrictMatcher: Matches table data (ignores punctuation/spacing)LooseMatcher: Matches natural text with flexible spacingSmartMatcher: Combines strategies and extracts sub-keywords (dates, numbers)MatchMerger: Merges overlapping match intervals
Highlighter (highlighter.py)
HTMLHighlighter: Applies CSS highlighting to matched DOM nodes- Cross-node matching support (keywords spanning multiple elements)
Pipeline (pipeline.py)
SECDataMiningPipeline: Orchestrates the complete workflow
Parquet Files (Accession ID → Keywords)
↓
ParquetReader (builds lookup table)
↓
HTML Files ──→ HTMLParser (extracts DOM)
↓
Full Text + Node Map
↓
Matcher (finds keyword positions)
↓
Merge Overlapping Matches
↓
HTMLHighlighter (modifies DOM)
↓
Output HTML (with highlights)
Process Form 4 (insider transaction) filings to automatically highlight:
- Transaction dates (MM/DD/YYYY)
- Share quantities
- Stock prices
- Executive names
Input Parquet: fraud_dedup_df_0000038725.parquet
file_name: "0000038725-25-000108_FRANKLIN...8-K_2025-05-08.html"
source_contents: ["05/20/2024", "$42.84", "718,848 shares", "Executive Name"]
Output: Same HTML with all matching text highlighted in yellow
Highlight specific financial metrics and key statements from 8-K, 10-K filings:
- Revenue figures
- Merger/acquisition announcements
- Restatements
- Officer changes
Extract and highlight competitive references and product mentions from 10-K filings
Combines multiple strategies:
- Extracts sub-keywords (dates, numbers) from complex strings
- Applies both strict and loose matching
- Best for table data with mixed formatting
Removes all punctuation/spacing before matching:
- Input: "05/20/2024S34,960D$42.84(1)718,848D"
- Cleaned: "052020243496042.84171884"
- Matches fragments like dates, amounts, quantities
Allows flexible whitespace but preserves punctuation:
- "Russell D. Fleeger" matches "Russell D. Fleeger"
- Useful for names and narrative text
On typical SEC filing batch (100+ HTML files with 10-20 keywords each):
- Speed: ~0.5-1.0 seconds per file
- Memory: ~50-100MB per 100 files
- Accuracy: 95%+ match accuracy with smart strategy
See examples/ directory for complete workflows:
basic_highlighting.py- Simple HTML highlight workflowbatch_processing.py- Process multiple SEC filingscustom_matching.py- Use custom matcher strategies
SEC-HTML-Data-Miner/
├── src/
│ ├── __init__.py
│ ├── parser.py # HTML/Parquet parsing
│ ├── matcher.py # Keyword matching strategies
│ ├── highlighter.py # DOM highlighting
│ ├── pipeline.py # Main workflow
│ └── cli.py # Command-line interface
├── tests/ # Unit tests
├── examples/ # Usage examples
├── data/
│ ├── sample_html/ # Sample SEC filings
│ └── sample_parquet/ # Sample keyword data
├── docs/ # Documentation
├── pyproject.toml # Project config
├── requirements.txt # Dependencies
└── README.md
pytest tests/ -v# Format code
black src/
# Lint
flake8 src/Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit changes (
git commit -am 'Add feature') - Push to branch (
git push origin feature/improvement) - Open a Pull Request
MIT License - see LICENSE file for details
Alex Wang - GitHub
- Built during internship at HSBC for SEC EDGAR data automation
- Inspired by need to scale financial document processing
- Dedicated to researchers and practitioners in financial analysis
Star the repo if you find this useful! ⭐