Quick and dirty date parsing Python library to parse HTML dates really fast
Project description
qddate — quick and dirty date parsing for scraped HTML
qddate is a Python 3 library focused on parsing date strings extracted from messy HTML pages as fast as possible. It was born out of long-term news aggregation work and is intentionally pragmatic: fewer abstractions, lots of hard-coded optimizations, and enough language coverage to process millions of strings at scale. The parser ships as part of the "news reconstruction" toolchain that can build RSS feeds for sites that never offered one.
If you need broader language coverage (but can trade speed for flexibility), check out dateparser or dateutil.
Documentation
Full documentation is automatically published at Read the Docs.
Features
- 712+ date patterns (expanded from 89 base patterns) and growing on demand
- Multi-language parsing (English, Russian, Spanish, Portuguese, and more)
- Handles left-aligned dates with trailing text:
12.03.1999 some text here - Prioritizes speed via pyparsing, hard-coded constants, and dirty tricks
Limitations
- Limited language coverage compared to larger projects
- Adding new languages requires editing pattern tables manually
- Rare/odd formats may still slip through
- No relative date parsing or calendar support
Speed Optimization
- All constants are embedded directly; no runtime configuration files
- Only depends on
datetimeandpyparsing(plus packaging tooling) - Avoids regular expressions in favor of pre-generated pyparsing patterns
- Aggressive pattern filtering using min/max length filters and prefix heuristics
- Nothing is loaded from disk at runtime besides the Python modules themselves
Benchmark & Performance Notes
- Standard benchmarks:
benchmarks/bench.pycompares qddate with dateparser on the bundled corpus. Runpython benchmarks/bench.pyto execute. - Webpage data benchmarks:
benchmarks/benchmark_webpage_data.pytests qddate against other libraries using real-world text snippets extracted from webpages. Usescripts/generate_webpage_test_data.pyto generate test data from government and international organization websites. - Comprehensive performance tests:
benchmarks/comprehensive_performance_test.pyprovides extensive performance testing with detailed metrics, pattern analysis, and regression detection. Seebenchmarks/README_PERFORMANCE_TEST.mdfor details. PERFORMANCE_ANALYSIS.mddocuments the 2025 profiling work (length-based indexing, prefix caching, packrat parsing, etc.) and how to evaluate future optimizations.- Benchmark numbers depend on hardware, Python version, and workload. Please share your results in issues if you run the benchmark elsewhere.
Usage
The simplest way to work with qddate is through qddate.DateParser and its parse method:
import qddate
parser = qddate.DateParser()
print(parser.parse('2012-12-15'))
print(parser.parse('Fri, 12 Dec 2014 10:55:50'))
print(parser.parse('пятница, июля 17, 2015'))
The parser auto-detects languages for each string and returns datetime.datetime instances when it finds a match.
Dependencies
Supported Languages
- Bulgarian
- Czech
- English
- French
- German
- Italian
- Polish
- Portuguese
- Russian
- Spanish
- Turkish
Thanks
The original parser dates back to 2008 and evolved from regular expressions into pyparsing over time. Thanks to the ScrapingHub team for the inspiration to clean up the code, documentation, and build tooling, and for motivating the public release.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qddate-1.0.8.tar.gz.
File metadata
- Download URL: qddate-1.0.8.tar.gz
- Upload date:
- Size: 92.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2738bf9d0078fb4ab104be8b8718c69e73655cfc6867a0a4d3e13eef54cf39c
|
|
| MD5 |
2fc5bd670cf68252fa76210418be42dd
|
|
| BLAKE2b-256 |
e28dbce4831ec5fd11c28aa9c972cc0d451cbfd8f30ff66de388a022244fb54c
|
File details
Details for the file qddate-1.0.8-py2.py3-none-any.whl.
File metadata
- Download URL: qddate-1.0.8-py2.py3-none-any.whl
- Upload date:
- Size: 115.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74314206f70ed9b95aa6525afa94bbc320755036e42f1afae7ad0841071ffd7e
|
|
| MD5 |
7582edbd142974f23f418e4e9cde3528
|
|
| BLAKE2b-256 |
dc3ab62c3150c5450774d0f7bb5d5a472dddd3790906dd773dc119e601f77822
|