update
This commit is contained in:
parent
406d664697
commit
de5a55298f
3 changed files with 441 additions and 307 deletions
|
@ -12,10 +12,11 @@ impl Source for Wikipedia {
|
|||
"https://en.wikipedia.org/wiki/War_Thunder".to_string()
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, err)]
|
||||
fn latest_leak(&self, html: &str) -> Result<time::Date> {
|
||||
let soup = soup::Soup::new(html);
|
||||
|
||||
let tables = soup.tag("table").find_all();
|
||||
let tables: Vec<_> = soup.tag("table").find_all().collect();
|
||||
|
||||
let tables_with_classified = tables
|
||||
.into_iter()
|
||||
|
@ -23,8 +24,9 @@ impl Source for Wikipedia {
|
|||
.collect::<Vec<_>>();
|
||||
|
||||
let table = match &tables_with_classified[..] {
|
||||
[] => bail!("No tables found"),
|
||||
[table] => table,
|
||||
_ => bail!("Cannot reliably find leaks table"),
|
||||
_ => bail!("Found more than one table with the string Classified"),
|
||||
};
|
||||
|
||||
let lines: Vec<String> = table
|
||||
|
@ -83,7 +85,7 @@ fn test_wikipedia_html_parse() {
|
|||
let html = std::fs::read_to_string("./data/wikipedia.html").unwrap();
|
||||
|
||||
let real = Wikipedia.latest_leak(&html).unwrap();
|
||||
let expected = time::Date::from_calendar_date(2023, time::Month::December, 12).unwrap();
|
||||
let expected = time::Date::from_calendar_date(2025, time::Month::June, 23).unwrap();
|
||||
|
||||
assert_eq!(expected, real);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue