1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-08 08:30:00 +02:00

start implementing readability

This commit is contained in:
Jan Lukas Gernert 2023-01-01 14:51:34 +01:00
parent c08f5afa5d
commit 2750ad648d
10 changed files with 375 additions and 124 deletions

View file

@ -145,6 +145,17 @@ impl Util {
None
}
pub fn get_attribute(
context: &Context,
xpath: &str,
attribute: &str,
) -> Result<String, FullTextParserError> {
Util::evaluate_xpath(context, xpath, false)?
.iter()
.find_map(|node| node.get_attribute(attribute))
.ok_or(FullTextParserError::Xml)
}
pub fn extract_value(context: &Context, xpath: &str) -> Result<String, FullTextParserError> {
let node_vec = Util::evaluate_xpath(context, xpath, false)?;
if let Some(val) = node_vec.get(0) {