lpkg/src/html.rs

15 lines
405 B
Rust
Raw Normal View History

2025-09-30 21:38:22 +02:00
use scraper::{Html, Selector};
2025-09-30 20:38:13 +02:00
2025-09-30 21:38:22 +02:00
pub fn fetch_pre_blocks(url: &str) -> anyhow::Result<Vec<String>> {
let body = reqwest::blocking::get(url)?.text()?;
let document = Html::parse_document(&body);
let selector = Selector::parse("pre").unwrap();
2025-09-30 20:38:13 +02:00
2025-09-30 21:38:22 +02:00
let mut results = Vec::new();
for element in document.select(&selector) {
results.push(element.inner_html());
2025-09-30 20:38:13 +02:00
}
2025-09-30 21:38:22 +02:00
Ok(results)
2025-09-30 20:38:13 +02:00
}