use mwbot::{Bot, parsoid::WikinodeIterator as _}; fn extract_number_from_url(url: &str) -> Option { // Split the URL into parts using '/' let parts: Vec<&str> = url.split('/').collect(); // Iterate over the parts to find the one that ends with ".html" for part in parts { if part.ends_with(".html") { // Remove the ".html" suffix let number_str = part.trim_end_matches(".html"); // Parse the remaining string into an integer return number_str.parse().ok(); } } None } pub async fn get_wsdc_id(bot: &Bot, page: &mwbot::Page) -> Option { let x = page.html().await.unwrap().into_mutable(); for w in &x.filter_external_links() { if let Some(id) = extract_number_from_url(&w.target()) { return Some(id); } } None } pub async fn get_description(bot: &Bot, page: &mwbot::Page) -> Option { let x = page.html().await.unwrap().into_mutable(); for w in &x.iter_sections() { dbg!(w); let Some(h) = w.heading() else { println!("No heading"); continue; }; dbg!(&h); let Some(t) = h.as_text() else { println!("No text"); continue; }; dbg!(t.borrow()); } None }