Collect a lot more data.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use log::debug;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -19,7 +20,8 @@ struct Props {
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct PageProps {
|
||||
phone_data: PhoneData,
|
||||
status_code: Option<u16>,
|
||||
phone_data: Option<PhoneData>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -65,17 +67,28 @@ impl Probe for Hitta {
|
||||
|
||||
if let Ok(data) = serde_json::from_str::<Data>(&json) {
|
||||
println!("hitta.se:");
|
||||
println!(" {}", data.props.page_props.phone_data.statistics_text);
|
||||
|
||||
for comment in &data.props.page_props.phone_data.comments {
|
||||
println!(" * {}", comment.comment);
|
||||
if let Some(phone_data) = data.props.page_props.phone_data {
|
||||
println!(" {}", phone_data.statistics_text);
|
||||
|
||||
for comment in &phone_data.comments {
|
||||
println!(" * {}", comment.comment);
|
||||
}
|
||||
} else {
|
||||
println!(" Vi hittar det mesta, men inte just den här sidan.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
if let Err(error) = serde_json::from_str::<Data>(&json) {
|
||||
debug!("Hitta: failed to deserialize data: {:#?}", error);
|
||||
}
|
||||
|
||||
Err(())
|
||||
}
|
||||
} else {
|
||||
debug!("Hitta: failed to find __NEXT_DATA__");
|
||||
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user