mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-08 16:40:00 +02:00
naivedatetime -> datetime utc
This commit is contained in:
parent
8f48b69161
commit
f51605a92c
3 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "article_scraper"
|
name = "article_scraper"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
authors = ["Jan Lukas Gernert <jangernert@gmail.com>"]
|
authors = ["Jan Lukas Gernert <jangernert@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::error::{ScraperError, ScraperErrorKind};
|
use crate::error::{ScraperError, ScraperErrorKind};
|
||||||
use chrono::NaiveDateTime;
|
use chrono::{DateTime, Utc};
|
||||||
use failure::ResultExt;
|
use failure::ResultExt;
|
||||||
use std;
|
use std;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -10,7 +10,7 @@ pub struct Article {
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
pub author: Option<String>,
|
pub author: Option<String>,
|
||||||
pub url: Url,
|
pub url: Url,
|
||||||
pub date: Option<NaiveDateTime>,
|
pub date: Option<DateTime<Utc>>,
|
||||||
pub html: Option<String>,
|
pub html: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use self::error::{ScraperError, ScraperErrorKind};
|
||||||
use crate::article::Article;
|
use crate::article::Article;
|
||||||
use crate::config::{ConfigCollection, GrabberConfig};
|
use crate::config::{ConfigCollection, GrabberConfig};
|
||||||
use crate::images::ImageDownloader;
|
use crate::images::ImageDownloader;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::DateTime;
|
||||||
use encoding_rs::Encoding;
|
use encoding_rs::Encoding;
|
||||||
use failure::ResultExt;
|
use failure::ResultExt;
|
||||||
use libxml::parser::Parser;
|
use libxml::parser::Parser;
|
||||||
|
@ -677,7 +677,7 @@ impl ArticleScraper {
|
||||||
for xpath_date in &config.xpath_date {
|
for xpath_date in &config.xpath_date {
|
||||||
if let Ok(date_string) = ArticleScraper::extract_value(&context, xpath_date) {
|
if let Ok(date_string) = ArticleScraper::extract_value(&context, xpath_date) {
|
||||||
debug!("Article date: '{}'", date_string);
|
debug!("Article date: '{}'", date_string);
|
||||||
if let Ok(date) = NaiveDateTime::from_str(&date_string) {
|
if let Ok(date) = DateTime::from_str(&date_string) {
|
||||||
article.date = Some(date);
|
article.date = Some(date);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue