diff --git a/src/main.rs b/src/main.rs index 75e02ed..0b70665 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,5 +23,7 @@ fn main() { for probe in &mut probes { probe.search(&mut ctx, &number); + + println!(); } } diff --git a/src/probe/eniro.rs b/src/probe/eniro.rs index e60099f..a31b0cb 100644 --- a/src/probe/eniro.rs +++ b/src/probe/eniro.rs @@ -1,6 +1,16 @@ +use unhtml::FromHtml; +use unhtml_derive::FromHtml; + use crate::context::Context; use crate::probe::Probe; +#[derive(Debug, FromHtml)] +#[html(selector = ".error-box")] +struct Error { + #[html(selector = "h2", attr = "inner")] + message: String, +} + // https://gulasidorna.eniro.se/hitta:{} pub struct Eniro; @@ -17,5 +27,10 @@ impl Probe for Eniro { ctx.cache_set("eniro", &number, body.as_bytes()) .expect("wut?! why not?!"); + + if let Ok(error) = Error::from_html(&body) { + println!("eniro.se:"); + println!(" {}", error.message); + } } } diff --git a/src/probe/hitta.rs b/src/probe/hitta.rs index 6fed71b..48270b2 100644 --- a/src/probe/hitta.rs +++ b/src/probe/hitta.rs @@ -27,7 +27,9 @@ struct PageProps { struct PhoneData { alternative_formats: Vec, clean_number: String, + #[serde(default)] comments: Vec, + statistics_text: String, } #[derive(Debug, Deserialize)] @@ -67,10 +69,8 @@ impl Probe for Hitta { let data: Data = serde_json::from_str(&json).unwrap(); - println!( - "hitta.se: {}", - data.props.page_props.phone_data.clean_number - ); + println!("hitta.se:"); + println!(" {}", data.props.page_props.phone_data.statistics_text); for comment in &data.props.page_props.phone_data.comments { println!(" * {}", comment.comment);