monolith/src/main.rs

50 lines
1.2 KiB
Rust
Raw Normal View History

2019-08-23 11:49:14 +02:00
#[macro_use]
2019-08-23 05:17:15 +02:00
extern crate clap;
extern crate monolith;
mod args;
use args::AppArgs;
use monolith::html::{html_to_dom, stringify_document, walk_and_embed_assets};
2019-09-29 23:15:49 +02:00
use monolith::http::retrieve_asset;
use monolith::utils::is_valid_url;
2019-08-23 05:17:15 +02:00
fn main() {
let app_args = AppArgs::get();
if is_valid_url(app_args.url_target.as_str()) {
2019-10-01 05:58:09 +02:00
let (data, final_url) = retrieve_asset(
app_args.url_target.as_str(),
false,
"",
app_args.user_agent.as_str(),
app_args.silent,
app_args.insecure,
)
.unwrap();
let dom = html_to_dom(&data);
2019-08-23 05:17:15 +02:00
walk_and_embed_assets(
2019-10-01 05:58:09 +02:00
&final_url,
&dom.document,
app_args.no_css,
app_args.no_js,
app_args.no_images,
app_args.user_agent.as_str(),
app_args.silent,
app_args.insecure,
app_args.no_frames,
);
let html: String = stringify_document(
&dom.document,
app_args.no_css,
app_args.no_frames,
app_args.no_js,
app_args.no_images,
app_args.isolate,
);
2019-08-23 05:17:15 +02:00
println!("{}", html);
2019-08-23 05:17:15 +02:00
}
}