mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2024-11-25 05:10:19 +00:00
Kill all the HTML images in favour of Markdown
This commit is contained in:
parent
7001e25e03
commit
b49400cd8b
2 changed files with 480 additions and 494 deletions
15
src/main.rs
15
src/main.rs
|
@ -9,7 +9,6 @@ use log::{warn, debug, info};
|
|||
use std::io::Write;
|
||||
use reqwest::{Client, redirect::Policy, StatusCode, header, Url};
|
||||
use regex::Regex;
|
||||
use scraper::{Html, Selector};
|
||||
use failure::{Fail, Error, format_err};
|
||||
use chrono::{Local, DateTime, Duration};
|
||||
use std::env;
|
||||
|
@ -287,19 +286,7 @@ async fn main() -> Result<(), Error> {
|
|||
}
|
||||
}
|
||||
Event::Html(content) => {
|
||||
let fragment = Html::parse_fragment(&content);
|
||||
for element in fragment.select(&Selector::parse("img").unwrap()) {
|
||||
let img_src = element.value().attr("src");
|
||||
if let Some(src) = img_src {
|
||||
do_check(src.to_string());
|
||||
}
|
||||
}
|
||||
for element in fragment.select(&Selector::parse("a").unwrap()) {
|
||||
let a_href = element.value().attr("href");
|
||||
if let Some(href) = a_href {
|
||||
do_check(href.to_string());
|
||||
}
|
||||
}
|
||||
return Err(format_err!("Contains HTML content, not markdown: {}", content));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue