Wget Download Entire Website

0 views
Skip to first unread message

Clarence Pariseau

unread,
Jan 25, 2024, 4:15:07 AM1/25/24
to rasmamesla

The commands -p -E -k ensure that you're not downloading entirepages that might be linked to (e.g. Link to a Twitter profile resultsin you downloading Twitter code) while including all pre-requisitefiles (JavaScript, css, etc.) that the site needs. Proper sitestructure is preserved as well (instead of one big .html file withembedded scripts/stylesheet that can sometimes be the output.

The commands -p -E -k ensure that you're not downloading entire pages that might be linked to (e.g. Link to a Twitter profile results in you downloading Twitter code) while including all pre-requisite files (JavaScript, css, etc.) that the site needs. Proper site structure is preserved as well (instead of one big .html file with embedded scripts/stylesheet that can sometimes be the output.

wget download entire website


Download ✒ ✒ ✒ https://t.co/7fXhpyntNH



In previous discussions (e.g. here and here, both of which are more than two years old), two suggestions are generally put forward: wget -p and httrack. However, these suggestions both fail. I would very much appreciate help with using either of these tools to accomplish the task; alternatives are also lovely.

wget -p successfully downloads all of the web page's prerequisites (css, images, js). However, when I load the local copy in a web browser, the page is unable to load the prerequisites because the paths to those prerequisites haven't been modified from the version on the web.

httrack seems like a great tool for mirroring entire websites, but it's unclear to me how to use it to create a local copy of a single page. There is a great deal of discussion in the httrack forums about this topic (e.g. here) but no one seems to have a bullet-proof solution.

You should be careful to check that .html extensions works for yourcase, sometimes you may want that wget generates them based on theContent Type but sometimes you should avoid wget generating them as isthe case when using pretty urls.

The offline documentation of Arch Wiki is a great example of this. I would like to have the same for the Void and Gentoo wiki (despite the memes their documentation pages are both really great resources for learning the Linux system). Simply wgetting every single page is doesn't seem like a solution because if you do so the hyperlinks will break.

We started a blog and I wrote an article that this community inspired. While it's labeled as advanced, I hope it's useful to someone who never used CLI or heard of wget. It's for those that really want to understand what each option does, and how to fine-tune it to the needs of a particular site. If you have any suggestions or corrections, do share. Please be gentle.

I want to download entire website but also resume the job if I want to kill it.My problem is that when I run the command the second time it never enters in the subfolders created previously.
I tried the option --mirror and --no-clobber too but the same error happenedNow I'm using the command like this:

Guys today i figured it out, the problem was not an option of recursion or continuation, but the 301 response back. I still don't understand why it's followed the first time, but now everything works well. I can stop the job and resume and after checking every file wget will download something new or continue previously download.As always happen someone had same problem and this is the link -wget/2019-11/msg00036.html

There are many possible uses and reasons why one might download an entire website. It does not matter if the target site is yours or not. On a side note, be careful about what you download. Perhaps you wish to conserve an era of a site with a particular design. Maybe you want to take an informative website with you to a place without internet. This method can ensure that a site stays with you even by the time you are a grandpa or a grandma. You could also host the now-static version of your website on Github Pages.

Some hosts might detect that you use wget to download an entire website and block you outright. Spoofing the User Agent is nice to disguise this procedure as a regular Chrome user. If the site blocks your IP, the next step would be continuing things through a VPN and using multiple virtual machines to download stratified parts of the target site (ouch). You might want to check out --wait and --random-wait options if your server is smart, and you need to slow down and delay requests.

Please understand that every server is different and what works on one, might be entirely wrong for the other. This is a starting point. There is a lot more to learn about archiving sites. Good luck with your data hoarding endeavors!

When we download a website for local offline use, we need it in full. Not just the html of a single page, but all required links, sub-pages, etc. Of course any cloud-based functionality will not work, but especially documentation is usually mostly static.

Besides wget, you may also use lftp in script mode. The following command will mirror the content of a given remote FTP directory into the given local directory, and it can be put into the cron job:

The first example downloads the page and creates a history what was copied in to a separate file. With this version you should be able to move to a new webroot on a webserver and use the Site as it was.
Of course you need to install all the services the website uses.

You have to take the second link with --convert-links. Otherwise when you click on a link it sends you to the website of itute. And i can not guarantie that you get all the files. It says default is 5 Level deep. It tries just once. You have endless settings you can adjust. Just check out wget --help

I do not have a reliable Internet connection and when I do get online, I am usually on a metered network. Not being able to connect to the Internet when I want to makes accessing online resources difficult. To solve this problem I use wget to download websites to my computer. I will show you how to do this yourself in this post.

After wget finishes downloading your website archive to your computer, you can check it out. Open the folder containing your downloaded website. In most cases, it defaults to a folder called web.archive.org.

The file gets downloaded to /home/publicus/Downloads/downloaded_websites/rosettacode.org. When I open up the index.html, I find that all of the links are pointing to /wiki/SomeArticle.html. What I don't understand is why are the links not pointing to /home/publicus/Downloads/downloaded_websites/rosettacode.org/wiki/SomeArticle.html? I really don't want to have to either fix this by hand or write a script that will fix this problem. Is there a command line argument that I've overlooked?

The example in OP already does download the entire site. The problem is that when you download the index.html page and mouse over -- for example -- "Add a Language" (on the downloaded instance) I get this link: file:///wiki/Rosetta_Code:Add_a_Language

So far I've successfully been able to mirror the site (with the above limitations), but I'm not sure if the command is actually mirroring the entire site as I need it to do. Here is the code I am using for wget:

It appears that the issue had to do with the fact that a "Logout" block was in the header of the main site. As a result, when wget went to pull things down, it would actually go to the logout link, and thus the rest of the files would either display a login screen or wouldn't be downloaded. By disabling the logout block OR adding --reject logout to my wget command, it seems to have fixed the issue and now the full directory structure is being downloaded. The command I ended up using was:

From time to time, an occasion might arise when you'd like to download an entire Web site. At my old job, I liked to pull down government sites and go on fishing expeditions with Google Desktop Search for hot terms (ex. names of corporations and political appointees) or certain file types (ex. Excel, Access, CSV, et cetera). And the other day at my current job a situation cropped up where the newsroom wanted to download a bunch of files quickly, so it was handy to set a spider loose rather than sit there and try to download everything click by click.

If you're working on a Macbook, the first thing you'll need to do is install wget. I'd suggest you do that by downloading the latest version and compiling the binary from the source code. That might sound scary, but it's just a fancy way of saying you're going to install something from the command line instead of clicking a bunch of pretty boxes. Some other sites are going to push you toward pretty boxes and maybe even this big bloated thing called Fink, but, trust me on this one, it's going to be a lot easier for you down the road if you learn how to install stuff yourself. And this is a simple enough example that it's worth the shot.

You've just compiled your first program. We just made a new directory for storing source code, downloaded wget's source, unzipped it, and then "made" the file with our XCode compiler. Pretty easy, right? The only catch is that you'll need your computer's administrator password to run the "sudo" command that will create wget's binary in your system folder.

Blammo, you're off to the races, walking your target's directory structure and saving all the files to your hard drive. The -m option puts wget in mirror mode and the -k option will convert all the hyperlinks so they're suitable for local viewing. Then you just feed it the URL you're after.

If you're a Linux or Windows user, the command should be the same. If you're a Windows user, you can try it with a release like this one. And if you run Linux, like I do, wget should already be installed and ready to roll in most distributions. No bothering with XCode or new downloads or any of that nonsense.

Scrapes can be useful to take static backups of websites or to catalogue a sitebefore a rebuild. If you do online courses then it can also be useful to have asmuch of the course material as possible locally. Another use is to download HTMLonly ebooks for offline reading.

8d45195817
Reply all
Reply to author
Forward
0 new messages