Added comment indicating the context under which the page was downloaded

This commit is contained in:
Emi Simpson 2020-01-08 18:51:18 -05:00
parent 929512f4f5
commit 27c9fb4cd3
No known key found for this signature in database
GPG key ID: 68FAB2E2E6DFC98B
3 changed files with 18 additions and 1 deletions

1
Cargo.lock generated
View file

@ -531,6 +531,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -19,6 +19,10 @@ lazy_static = "1.4.0"
regex = "1.3.1"
url = "2.1.0"
# Used to render comments indicating the time the page was saved
# also required by reqwest as of v0.10.0
time = "0.1.42"
[dependencies.reqwest]
version = "0.10.*"
default-features = false

View file

@ -71,6 +71,7 @@ fn main() {
app_args.silent,
)
.unwrap();
let downloaded_time = time::now();
let dom = html_to_dom(&data);
walk_and_embed_assets(
@ -85,7 +86,7 @@ fn main() {
app_args.no_frames,
);
let html: String = stringify_document(
let mut html: String = stringify_document(
&dom.document,
app_args.no_css,
app_args.no_frames,
@ -94,6 +95,17 @@ fn main() {
app_args.isolate,
);
html.insert_str(
0,
&format!(
"<!--- Downloaded from {} on {}using {} v{} -->\n",
&final_url,
downloaded_time.to_local().rfc822(),
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
),
);
if app_args.output == str!() {
println!("{}", html);
} else {