An article’s author and publication date are claims made by its publisher. Extract the candidates from the page, retain where each came from, and leave conflicts visible. A date in the URL or a retrieval timestamp is not proof of when the article was published.
Start with the original HTML. A text extraction can drop the head metadata, and a clean Markdown body does not guarantee that an author or publication date is present.
Keep publication and modification dates separate
Useful candidates include an author meta tag, article publication metadata and JSON-LD with author, datePublished or dateModified. Their meanings differ: a modification date should not silently replace a missing publication date. A JSON-LD author can be a person, an organization or a list.
The Schema.org author and datePublished definitions describe the fields, not the truth of a particular page’s values. A publisher can supply contradictory or incorrect metadata.
Extract candidates without choosing a winner
This Python standard-library example parses explicit metadata and article JSON-LD. It does not execute scripts, infer a byline from arbitrary prose or invent a missing date. Its synthetic fixture deliberately contains two authors and two publication dates.
from html.parser import HTMLParser
import json
class Metadata(HTMLParser):
def __init__(self):
super().__init__()
self.candidates, self.errors = [], []
self.in_json, self.parts = False, []
def add(self, field, value, source):
if isinstance(value, str) and value.strip():
item = {"field": field, "value": value.strip(), "source": source}
if item not in self.candidates:
self.candidates.append(item)
def handle_starttag(self, tag, attrs):
attrs = dict(attrs)
if tag == "meta":
key = (attrs.get("property") or attrs.get("name") or "").lower()
fields = {"author": "author", "article:author": "author",
"article:published_time": "published",
"article:modified_time": "modified"}
if key in fields:
self.add(fields[key], attrs.get("content"), "meta:" + key)
if tag == "script" and attrs.get("type", "").lower() == "application/ld+json":
self.in_json, self.parts = True, []
def handle_data(self, value):
if self.in_json:
self.parts.append(value)
def handle_endtag(self, tag):
if tag == "script" and self.in_json:
self.in_json = False
try:
self.visit(json.loads("".join(self.parts)))
except (ValueError, TypeError, RecursionError):
self.errors.append("JSON-LD could not be parsed")
def visit(self, node):
if isinstance(node, list):
for item in node:
self.visit(item)
elif isinstance(node, dict):
kinds = node.get("@type", [])
kinds = [kinds] if isinstance(kinds, str) else kinds
if isinstance(kinds, list) and set(kinds) & {"Article", "NewsArticle", "BlogPosting"}:
authors = node.get("author", [])
authors = authors if isinstance(authors, list) else [authors]
for author in authors:
self.add("author", author.get("name") if isinstance(author, dict)
else author, "jsonld:author")
self.add("published", node.get("datePublished"), "jsonld:datePublished")
self.add("modified", node.get("dateModified"), "jsonld:dateModified")
self.visit(node.get("@graph", []))
fixture = '''<meta name="author" content="Writer A">
<meta property="article:published_time" content="2026-01-02T10:00:00Z">
<script type="application/ld+json">{"@type":"NewsArticle",
"author":{"name":"Writer B"},"datePublished":"2026-01-03T10:00:00Z",
"dateModified":"2026-01-04T10:00:00Z"}</script>'''
parser = Metadata()
parser.feed(fixture)
assert {x["value"] for x in parser.candidates if x["field"] == "author"} == {
"Writer A", "Writer B"}
assert len([x for x in parser.candidates if x["field"] == "published"]) == 2
assert len([x for x in parser.candidates if x["field"] == "modified"]) == 1
assert not parser.errors
print(json.dumps(parser.candidates, indent=2))
The output retains both bylines and both publication candidates. It does not call either one correct. In a real collection record, attach the source URL, retrieval time and content revision to this result.
Review conflicts against the visible page
Check a disputed candidate against the byline and date shown with the article. A meta tag may belong to a template, a syndicated copy may name a different publisher, and a date may refer to an update. Retain the original value and locator while deciding which interpretation the application can accept.
- Keep missing metadata as missing. Do not substitute the current time.
- Keep a date-only value distinct from a timestamp with a timezone.
- Resolve linked author identities separately; the example only collects literal names or strings.
- Keep JSON-LD parse errors visible rather than reporting an empty list as a clean success.
The parser supports the explicit shapes shown here. It does not resolve JSON-LD @id references, custom contexts, every schema type or dynamically inserted metadata. Add fixtures for the sources you actually collect, and review unsupported cases.
Fetch the representation that contains the evidence
When using the SearchCans Reader API, request HTML when you need to inspect metadata and check the returned field before parsing it. If the required HTML is absent or a rendered page still lacks a date, keep an unresolved result. Do not assume an undocumented metadata object provides an authoritative author or publication time.
Use headless rendering only when the required content depends on JavaScript, and verify the result. Rendering and proxy selection are separate controls, and neither guarantees complete metadata. An extraction endpoint also does not certify the rights, privacy or legal suitability of downstream use.
For keeping the accepted source record through ingestion, use the LlamaIndex metadata workflow. Author and date extraction supplies provenance candidates; it does not establish that the document’s factual claims are correct.