Crate article_date_extractor [] [src]

This crate provides a library for extracting the publication date from an article or a blog post. It was heavily influenced by both the original article-date-extractor written in Python, as well as its Haskell port.

Usage

This crate is on crates.io and can be used by adding article_date_extractor to your dependencies in your project's Cargo.toml.

[dependencies]
article-date-extractor = "0.1.0"

and this to your crate root:

extern crate article_date_extractor;

Example: extracting a date from a news article

extract_article_published_date expects both a link as well as an html body. In the following example the body is provided as part of the library's test fixtures.

extern crate article_date_extractor;
extern crate chrono;

fn main() {
    use article_date_extractor::extract_date::extract_article_published_date;
    use chrono::NaiveDate;
    use std::env;

    let link = "http://edition.cnn.com/2015/11/28/opinions/sutter-cop21-paris-preview-two-degrees/index.html";
    let body = include_str!("./tests/fixtures/cnn.html");

    assert_eq!(NaiveDate::from_ymd(2015, 11, 28), extract_article_published_date(&link, body).unwrap());
}

Modules

extract_date