Move code around.

This commit is contained in:
2018-12-18 13:33:53 +01:00
parent 97103a9775
commit 9bf1d22876
7 changed files with 93 additions and 66 deletions

32
src/probe/hitta.rs Normal file
View File

@@ -0,0 +1,32 @@
use scraper::{Html, Selector};
use crate::probe::Probe;
// https://www.hitta.se/vem-ringde/{}
pub struct Hitta;
impl Probe for Hitta {
fn search(&mut self, number: &str) {
let body = reqwest::get(&format!("https://www.hitta.se/vem-ringde/{}", number))
.unwrap()
.text()
.unwrap();
let document = Html::parse_document(&body);
let selector = Selector::parse(r#"div[class^="Header__WhoCalledHeader"] > h1"#).unwrap();
print!("Hitta.se:");
for element in document.select(&selector) {
println!(" {}", element.text().collect::<String>());
}
// Comments.
let selector = Selector::parse(r#".topComment--comment"#).unwrap();
for element in document.select(&selector) {
println!(" * {}", element.text().collect::<String>());
}
}
}