Download a website with wget

A website can be downloaded using wget using the following command:

 
 

plaintextCopy code

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent <网站地址>

Among them, the meaning of each parameter is as follows:

  • --mirror: Mirrors the entire website, including subdirectories and files.
  • --convert-links: Convert links in downloaded files to point to local files for offline browsing.
  • --adjust-extension: Corresponds the file extension to the MIME type.
  • --page-requisites: Downloads all attached files in the HTML document, such as images, style sheets, and JavaScript files.
  • --no-parent: Do not drill down to parent directories. For example, if you want to download the Baidu homepage, you can use the following command:

--adjust-extensionis an option to the wget command that maps the extensions of downloaded files to their corresponding MIME types. MIME types, short for Multipurpose Internet Mail Extensions, are used to identify file format types on the Internet. When downloading a file, the server usually tells the client the MIME type of the file, and the client will determine the default extension of the file based on the MIME type. However, in some cases, the server does not set the MIME type correctly, or the user specifies an incorrect extension when downloading the file, which will cause the file to not be opened correctly. Using --adjust-extensionthe option allows wget to automatically adjust the file extension according to the file's MIME type, avoiding this problem and improving the usability of downloaded files.

Guess you like

Origin blog.csdn.net/ihateright/article/details/131354611
Recommended