mirror of
https://github.com/rust-unofficial/awesome-rust.git
synced 2024-11-21 10:45:55 +02:00
Kill all the HTML images in favour of Markdown
This commit is contained in:
parent
7001e25e03
commit
b49400cd8b
15
src/main.rs
15
src/main.rs
@ -9,7 +9,6 @@ use log::{warn, debug, info};
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use reqwest::{Client, redirect::Policy, StatusCode, header, Url};
|
use reqwest::{Client, redirect::Policy, StatusCode, header, Url};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use scraper::{Html, Selector};
|
|
||||||
use failure::{Fail, Error, format_err};
|
use failure::{Fail, Error, format_err};
|
||||||
use chrono::{Local, DateTime, Duration};
|
use chrono::{Local, DateTime, Duration};
|
||||||
use std::env;
|
use std::env;
|
||||||
@ -287,19 +286,7 @@ async fn main() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Html(content) => {
|
Event::Html(content) => {
|
||||||
let fragment = Html::parse_fragment(&content);
|
return Err(format_err!("Contains HTML content, not markdown: {}", 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user