Added some basic logging.
Fix cache invalidation (1 day for now).
This commit is contained in:
@@ -39,22 +39,24 @@ struct Comment {
|
||||
timestamp: u64,
|
||||
}
|
||||
|
||||
// https://www.hitta.se/vem-ringde/{}
|
||||
pub struct Hitta;
|
||||
|
||||
impl Probe for Hitta {
|
||||
fn uri(&self, number: &str) -> String {
|
||||
format!("https://www.hitta.se/vem-ringde/{}", number)
|
||||
}
|
||||
|
||||
fn search(&mut self, ctx: &mut Context, number: &str) -> Result<(), ()> {
|
||||
let body = if let Some(cache) = ctx.cache_get("hitta", &number) {
|
||||
String::from_utf8(cache.data).unwrap()
|
||||
} else {
|
||||
reqwest::get(&format!("https://www.hitta.se/vem-ringde/{}", number))
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap()
|
||||
};
|
||||
let body = reqwest::get(&self.uri(number)).unwrap().text().unwrap();
|
||||
|
||||
ctx.cache_set("hitta", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
ctx.cache_set("hitta", &number, body.as_bytes())
|
||||
.expect("wut?! why not?!");
|
||||
|
||||
body
|
||||
};
|
||||
|
||||
let re = Regex::new(r#"<script>__NEXT_DATA__ = (.*?);__NEXT_LOADED_PAGES__"#).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user