Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ivbeg/qddate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qddate — quick and dirty date parsing for scraped HTML

Build Status PyPI Version Docs Coverage Gitter

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

  • 348+ date patterns as of 2017 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 datetime and pyparsing (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

  • Benchmarks live in benchmarks/bench.py. Run python benchmarks/bench.py to compare qddate with dateparser on the bundled corpus.
  • PERFORMANCE_ANALYSIS.md documents 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
  • Polish
  • Portuguese
  • Russian
  • Spanish

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.

About

Quick and dirty date parsing Python library to parse HTML dates really fast

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •