(html: &str)
| 13 | } |
| 14 | |
| 15 | pub fn extract_text_from_html(html: &str) -> String { |
| 16 | let document = Html::parse_document(html); |
| 17 | let selector = Selector::parse("body").unwrap(); |
| 18 | |
| 19 | document |
| 20 | .select(&selector) |
| 21 | .flat_map(|element| element.text()) |
| 22 | .map(|text| text.trim()) |
| 23 | .filter(|text| !text.is_empty()) |
| 24 | .collect::<Vec<_>>() |
| 25 | .join(" ") |
| 26 | } |
| 27 | |
| 28 | pub fn coarse_remove_large_chunks(cur_chunks: Vec<String>) -> Vec<String> { |
| 29 | let max_chunk_len = 10000; |