Skip to content
ywu24Public

About

Publication date extractor for italian newspapers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Datario

Yi Hao Wu   Fabio Pastore   Alessandro Zannone
Built by Yi Hao Wu · Fabio Pastore · Alessandro Zannone

Publication date extractor for Italian newspaper pages. A FastAPI microservice that accepts a URL or raw HTML and returns the publication date in ISO 8601 format, using a generic parsing chain for most sites and domain-specific extractors to handle edge cases.

Features

  • POST /extract — accept a url or raw html body, get back the publication date (or null).
  • GET /domain_eval / GET /full_eval — score extraction accuracy against the ground-truth dataset.
  • 8-strategy generic parsing chain (published_time metadata, OpenGraph/JSON-LD microdata, <time> tags, URL date patterns, etc.) plus domain-specific extractors for ~33 sites.
  • Layered fetch pipeline (curl_cffi TLS impersonation → headless Chromium → search-engine snippet fallbacks) to bypass bot detection.

Quick start

Local development uses the py launcher with an editable install (no venv):

py -m pip install -e ".[dev]"
uvicorn datario.main:app --reload --port 8000

Or via Docker:

docker compose up --build

The API will be available at http://localhost:8000.

Debug prints are off by default, to enable them uncomment the debug=true line in .config.

To add more domain-specific extractors, create a new class in datario/extractors/ and import it in datario/extractors/extractor_factory/__init__.py. Also update __DOMAIN_EXCEPTIONS in datario/extractors/BaseExtractor.py.

API

POST /extract

Either url or html must be provided (at least one).

{ "url": "https://www.ansa.it/sito/notizie/2026/07/22/..." }
{ "html": "<html>...<meta property=\"article:published_time\" content=\"2026-07-22T07:48:00.000Z\"/>...</html>" }

Response:

{ "date": "2026-07-22T07:48:00+00:00" }

date is null when no publication date can be found. Errors: 400 malformed URL, 502 fetch failure, 500 extraction failure.

GET /domain_eval?domain=www.ansa.it

Accuracy for a single domain from the ground-truth dataset.

GET /full_eval

Overall accuracy across all domains. Concurrency is capped at 5 domains to avoid 403s.

Ground truth and evaluation

src/datario/gs_data.json holds 218 domain keys with 3 article URLs each, mapping each URL to its expected date.

The HTTP eval endpoints hit the live network. For iteration, prefer the offline eval loop against the committed HTML cache in src/datario/html/:

py scripts/fetch_html.py                 # cache article HTML for all gs_data URLs
py scripts/eval_local.py                 # full eval over the cache
py scripts/eval_local.py www.ansa.it     # single domain
py scripts/eval_local.py --url <article> # single URL, detailed output
py scripts/inspect_domain.py www.ansa.it # dump cached HTML metadata for a domain

After regenerating the cache, keep url_to_cache.json and src/datario/html/ in sync:

py scripts/map_urls_to_cache.py
py scripts/prune_html_cache.py

Project layout

src/datario/
  main.py          — FastAPI app + eval endpoints
  models.py        — request/response schemas
  fetcher.py       — layered fetch: curl_cffi → Playwright → Startpage → DuckDuckGo Lite
  gs_data.json     — ground-truth dates for eval
  html/            — cached article HTML for offline eval (not shipped in Docker)
  extractors/      — BaseExtractor fallback chain + ~30 domain-specific subclasses
scripts/           — local eval and cache-management tooling

License

See LICENSE.

About

Publication date extractor for italian newspapers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages