24 lines
646 B
Rust
24 lines
646 B
Rust
use crate::context::Context;
|
|
use crate::probe::Probe;
|
|
|
|
// http://vemringde.se/?q={}
|
|
pub struct VemRingde;
|
|
|
|
impl Probe for VemRingde {
|
|
fn search(&mut self, ctx: &mut Context, number: &str) -> Result<(), ()> {
|
|
let body = if let Some(cache) = ctx.cache_get("vem_ringde", &number) {
|
|
String::from_utf8(cache.data).unwrap()
|
|
} else {
|
|
reqwest::get(&format!("http://vemringde.se/?q={}", number))
|
|
.unwrap()
|
|
.text()
|
|
.unwrap()
|
|
};
|
|
|
|
ctx.cache_set("vem_ringde", &number, body.as_bytes())
|
|
.expect("wut?! why not?!");
|
|
|
|
Err(())
|
|
}
|
|
}
|