Cache works, but needs a lot more work.
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
use scraper::{Html, Selector};
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::probe::Probe;
|
||||
|
||||
// http://vemringde.se/?q={}
|
||||
pub struct VemRingde;
|
||||
|
||||
impl Probe for VemRingde {
|
||||
fn search(&mut self, _: &str) {}
|
||||
fn search(&mut self, ctx: &mut Context, number: &str) {
|
||||
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?!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user