Add more logic for konsumentinfo.se, telefonforsaljare.nu, and handle error for hitta.se.
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
use unhtml::FromHtml;
|
||||
use unhtml_derive::FromHtml;
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::probe::Probe;
|
||||
|
||||
#[derive(Debug, FromHtml)]
|
||||
#[html(selector = "[itemtype='//data-vocabulary.org/Review-aggregate']")]
|
||||
struct Info {
|
||||
#[html(selector = "p", attr = "inner")]
|
||||
message: String,
|
||||
}
|
||||
|
||||
// http://www.telefonforsaljare.nu/telefonnummer/{}/
|
||||
pub struct Telefonforsaljare;
|
||||
|
||||
@@ -20,5 +30,13 @@ impl Probe for Telefonforsaljare {
|
||||
|
||||
ctx.cache_set("telefonforsaljare", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
|
||||
println!("telefonforsaljare.nu:");
|
||||
|
||||
if let Ok(info) = Info::from_html(&body) {
|
||||
println!(" {}", info.message);
|
||||
} else {
|
||||
println!(" Failed to find any data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user