mirror of
https://gitlab.com/news-flash/article_scraper.git
synced 2025-07-08 08:30:00 +02:00
wip: test libxml XML_SAVE_NO_EMPTY option
This commit is contained in:
parent
a44ac3663c
commit
a99b8dec47
2 changed files with 64 additions and 0 deletions
|
@ -46,6 +46,7 @@ impl ImageDownloader {
|
|||
self.download_images_from_context(&xpath_ctx)?;
|
||||
|
||||
Ok(doc.to_string(/*format:*/ false))
|
||||
//Ok(doc.to_string_custom())
|
||||
}
|
||||
|
||||
pub fn download_images_from_context(&self, context: &Context) -> Result<(), ImageDownloadError> {
|
||||
|
@ -236,4 +237,24 @@ impl ImageDownloader {
|
|||
}
|
||||
Err(ImageDownloadErrorKind::ContentLenght)?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
|
||||
#[test]
|
||||
pub fn close_tags() {
|
||||
let image_dowloader = ImageDownloader::new((2048, 2048));
|
||||
let hdyleaflet = fs::read_to_string(r"./resources/tests/planetGnome/fedora31.html")
|
||||
.expect("Failed to read HTML");
|
||||
let result = image_dowloader.download_images_from_string(&hdyleaflet)
|
||||
.expect("Failed to downalod images");
|
||||
let mut file = fs::File::create(r"./resources/tests/planetGnome/fedora31_images_downloaded.html")
|
||||
.expect("Failed to create output file");
|
||||
file.write_all(result.as_bytes()).expect("Failed to write result to file");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue