How htmldate extracts dates
masterHtmldate uses a multi-layered heuristic approach to identify dates within HTML markup and text:
- Markup in header: Searches for
linkandmetaelements, including Open Graph protocol attributes. - HTML code: Scans the document for structural markers like
abbrortimeelements and specific attributes (e.g.,postmetadata). - Bare HTML content:
- Fast mode: Cleans the HTML and targets precise patterns.
- Extensive mode: Collects all potential dates and uses a disambiguation algorithm to select the most likely candidate.
Finally, the detected date is validated and converted to the requested format (defaulting to ISO 8601 YMD).