Better handling.

This commit is contained in:
2019-01-17 15:34:11 +01:00
parent 31922bbc3f
commit eb0bfd4e71
3 changed files with 15 additions and 8 deletions

View File

@@ -12,9 +12,9 @@ $ whoareyou 0700000000
Almost everything. I will add stuff when I need stuff. But hey, if you found this project and want to use it. Fork it, change it, create a PR, and I will add it :)
[ ] Add flag to open url for probes in browser (easier for debugging)
[x] Probe should return and Result, so we don't print a new line for empty result
[ ] Add logging
[ ] List cache entries
[ ] Clear cache entries
[ ] Add some nice colors, so it's easier to read the output.
- [x] Add flag to open url for probes in browser (easier for debugging)
- [x] Probe should return and Result, so we don't print a new line for empty result
- [x] Add logging
- [ ] List cache entries
- [ ] Clear cache entries
- [ ] Add some nice colors, so it's easier to read the output.

View File

@@ -17,7 +17,7 @@ struct Page {
#[derive(Debug, FromHtml)]
#[html(selector = "#content")]
struct Content {
#[html(selector = "p:nth-child(2)", attr = "inner")]
#[html(selector = "p:nth-child(2)", attr = "inner", default = "")]
title: String,
#[html(selector = "p:nth-child(5)", attr = "inner")]
@@ -58,7 +58,10 @@ impl Probe for Telefonforsaljare {
println!("telefonforsaljare.nu:");
if let Ok(page) = Page::from_html(&body) {
if !page.content.title.is_empty() {
println!(" {}", page.content.title);
}
println!(" {}", page.content.history);
for comment in &page.comments {

View File

@@ -74,6 +74,10 @@ impl Probe for VemRingde {
println!(" * {}: {}", call.date, call.who);
}
}
if page.owners.is_empty() && page.calls.is_empty() {
println!(" Inga samtal från {}", number);
}
} else {
if let Err(error) = Page::from_html(&body) {
debug!("vemringde: failed to parse page: {:#?}", error);