2019-08-23 11:49:14 +02:00
|
|
|
#[macro_use]
|
2019-08-23 05:17:15 +02:00
|
|
|
extern crate clap;
|
|
|
|
extern crate monolith;
|
|
|
|
|
2019-10-10 07:28:12 +02:00
|
|
|
mod args;
|
|
|
|
|
|
|
|
use args::AppArgs;
|
2019-09-22 02:06:00 +02:00
|
|
|
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() {
|
2019-10-10 07:28:12 +02:00
|
|
|
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(
|
2019-10-10 07:28:12 +02:00
|
|
|
app_args.url_target.as_str(),
|
2019-09-22 02:06:00 +02:00
|
|
|
false,
|
|
|
|
"",
|
2019-10-10 07:28:12 +02:00
|
|
|
app_args.user_agent.as_str(),
|
|
|
|
app_args.silent,
|
|
|
|
app_args.insecure,
|
2019-09-22 02:06:00 +02:00
|
|
|
)
|
|
|
|
.unwrap();
|
2019-08-24 05:06:06 +02:00
|
|
|
let dom = html_to_dom(&data);
|
2019-08-23 05:17:15 +02:00
|
|
|
|
2019-08-24 05:06:06 +02:00
|
|
|
walk_and_embed_assets(
|
2019-10-01 05:58:09 +02:00
|
|
|
&final_url,
|
2019-08-24 05:06:06 +02:00
|
|
|
&dom.document,
|
2019-10-10 07:28:12 +02:00
|
|
|
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,
|
2019-09-22 02:06:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let html: String = stringify_document(
|
|
|
|
&dom.document,
|
2019-10-10 07:28:12 +02:00
|
|
|
app_args.no_css,
|
|
|
|
app_args.no_frames,
|
|
|
|
app_args.no_js,
|
|
|
|
app_args.no_images,
|
|
|
|
app_args.isolate,
|
2019-08-24 05:06:06 +02:00
|
|
|
);
|
2019-08-23 05:17:15 +02:00
|
|
|
|
2019-09-22 02:06:00 +02:00
|
|
|
println!("{}", html);
|
2019-08-23 05:17:15 +02:00
|
|
|
}
|
|
|
|
}
|