Giter Site home page Giter Site logo

jamison413 / adbar-htmldate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adbar/htmldate

0.0 1.0 0.0 13.95 MB

Fast and robust date extraction from web pages, with Python or on the command-line

Home Page: https://htmldate.readthedocs.io

License: GNU General Public License v3.0

Python 100.00%

adbar-htmldate's Introduction

htmldate: find the publication date of web pages

Python package Python versions Documentation Status Code Coverage Downloads JOSS article reference DOI: 10.21105/joss.02439 Code style: black

Logo as PNG image


Find original and updated publication dates of any web page. From the command-line or within Python, all the steps needed from web page download to HTML parsing, scraping, and text analysis are included.

In a nutshell


Demo as GIF image

With Python:

>>> from htmldate import find_date
>>> find_date('http://blog.python.org/2016/12/python-360-is-now-available.html')
'2016-12-23'

On the command-line:

$ htmldate -u http://blog.python.org/2016/12/python-360-is-now-available.html
'2016-12-23'

Features

  • Multilingual, robust and efficient (used in production on millions of documents)
  • URLs, HTML files, or HTML trees are given as input (includes batch processing)
  • Output as string in any date format (defaults to ISO 8601 YMD)
  • Detection of both original and updated dates
  • Compatible with all recent versions of Python

htmldate can examine markup and text. It provides the following ways to date an HTML document:

  1. Markup in header: Common patterns are used to identify relevant elements (e.g. link and meta elements) including Open Graph protocol attributes
  2. HTML code: The whole document is searched for structural markers: abbr or time elements and a series of attributes (e.g. postmetadata)
  3. Bare HTML content: Heuristics are run on text and markup:
  • in fast mode the HTML page is cleaned and precise patterns are targeted
  • in extensive mode all potential dates are collected and a disambiguation algorithm determines the best one

Finally the output is validated and converted to the chosen format.

Performance

500 web pages containing identifiable dates (as of 2022-11-28 on Python 3.8)
Python Package Precision Recall Accuracy F-Score Time
articleDateExtractor 0.20 0.769 0.691 0.572 0.728 4x
date_guesser 2.1.4 0.738 0.544 0.456 0.626 16x
goose3 3.1.12 0.821 0.453 0.412 0.584 14x
htmldate[all] 1.4.0 (fast) 0.856 0.921 0.798 0.888 1x
htmldate[all] 1.4.0 (extensive) 0.847 0.991 0.840 0.913 2.2x
newspaper3k 0.2.8 0.729 0.630 0.510 0.675 13x
news-please 1.5.22 0.769 0.691 0.572 0.728 38x

For complete results and explanations see the evaluation page.

Installation

This Python package is tested on Linux, macOS and Windows systems; it is compatible with Python 3.6 upwards. It is available on the package repository PyPI and can notably be installed with pip (pip3 where applicable): pip install htmldate and optionally pip install htmldate[speed].

Documentation

For more details on installation, Python & CLI usage, please refer to the documentation: htmldate.readthedocs.io

License

htmldate is distributed under the GNU General Public License v3.0. If you wish to redistribute this library but feel bounded by the license conditions please try interacting at arms length, multi-licensing with compatible licenses, or contacting me.

See also GPL and free software licensing: What's in it for business?

Author

This effort is part of methods to derive information from web documents in order to build text databases for research (chiefly linguistic analysis and natural language processing). Extracting and pre-processing web texts to the exacting standards of scientific research presents a substantial challenge for those who conduct such research. There are web pages for which neither the URL nor the server response provide a reliable way to find out when a document was published or modified. For more information:

JOSS article reference DOI: 10.21105/joss.02439 Zenodo archive DOI: 10.5281/zenodo.3459599
@article{barbaresi-2020-htmldate,
  title = {{htmldate: A Python package to extract publication dates from web pages}},
  author = "Barbaresi, Adrien",
  journal = "Journal of Open Source Software",
  volume = 5,
  number = 51,
  pages = 2439,
  url = {https://doi.org/10.21105/joss.02439},
  publisher = {The Open Journal},
  year = 2020,
}

You can contact me via my contact page or GitHub.

Contributing

Contributions are welcome!

Feel free to file issues on the dedicated page. Thanks to the contributors who submitted features and bugfixes!

Kudos to the following software libraries:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.