[wget] Syntax to download single HTML page and its dependencies?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
That code snippet appears to have a zero rather than an uppercase. Maybe use the long version of the option to be sure:
Code:
--output-document=file
I also note in the wget man page:
Quote:
Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the rest to their normal names: all downloaded content will be placed in file. This was
disabled in version 1.11, but has been reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.
Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative URIs to external ones; -k makes no sense for multiple URIs when they're all being
downloaded to a single file; -k can be used only when the output is a regular file.
That said, what does (or doesn't) happen for you?
Another option is not use -O and simply redirect the output to a file
wget -E -H -k -K -p -e robots=off --output-document=local.html https://www.acme.com/mypage.html
Cannot specify both -k or --convert-file-only and -O if multiple URLs are given, or in combination with -p or -r. See the manual for details.
The redirection creates an empty file at the root, and I can find no local.html anywhere.
Last edited by littlebigman; 04-27-2020 at 02:36 PM.
wget -E -H -k -K -p -e robots=off --output-document=local.html https://www.acme.com/mypage.html
Cannot specify both -k or --convert-file-only and -O if multiple URLs are given, or in combination with -p or -r. See the manual for details.
The redirection creates an empty file at the root, and I can find no local.html anywhere.
That's a pretty clear error message, and is what the man page section I copied says as well. It simply won't work. -k and -O can't be used in the same command. Try it without the -k, or the -O (which you said worked, yes?)
What happens without the -O? Several files? Can you cat them together?
You do know that most browsers can do this?
Caveat: the "dependencies" are placed in a separate folder that needs to travel with the original downloaded file.
But I believe you will have the same caveat with wget, or curl for that matter.
It might be possible to convert the whole pile into something that is one file only, but that goes beyond mere downloading.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.