System/OS
2020.09.03 03:05

How to Install and Use wget on Mac

조회 수 1288 추천 수 0 댓글 0
Atachment
첨부 '4'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

wget00.jpg


wget is a non-interactive command-line utility for download resources from a specified URL. Because it is non-interactive, wget can work in the background or before the user even logs in. The program was designed especially for poor connections, making it especially robust in otherwise flaky conditions. While wget isn’t shipped with macOS, it can be easily downloaded and installed with Homebrew, the best Mac package manager available.

1. Download and Install Homebrew

wget01.png

To install Homebrew, open a Terminal window and execute the following command taken from Homebrew’s website:

Install Homebrew

mac:~ hooni$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
mac:~ hooni$ brew update
mac:~ hooni$ brew doctor



You might notice the command called curl, which is a different command-line utility for downloading files from a URL that ships within the Ruby installation included on macOS.

2. Installing wget

Once it has completed installing itself, we will use Homebrew to install wget. In Terminal, run the following command to download and install wget:

Install wget

mac:~ hooni$ brew install wget



You’ll get live updates on the progress of downloading and installing whatever dependencies (software prerequisites) are required to run wget on your system.

If you already have Homebrew installed, be sure to run brew update to get the latest copies of all your formulae.

3. Using wget

wget03.jpg

The purpose of wget is downloading content from URLs. It’s a quick and simple non-interactive tool for downloading files from any publicly accessible URL.

Download a single file

Like the similar command curl, wget takes a remote resource from a URL and saves it to a specified location on your computer. The command’s structure works like so:

mac:~ hooni$ wget -O path/to/local.copy http://example.com/url/to/download.html



That will save the file specified in the URL to the location specified on your machine. If the -O flag is excluded, the specified URL will be downloaded to the present working directory.

Download a directory recursively

To download an entire directory tree with wget, you need to use the -r/--recursive and -np/--no-parent flags, like so:

mac:~ hooni$ wget -e robots=off -r -np https://www.w3.org/History/19921103-hypertext/hypertext/



This will cause wget to follow any links found on the documents within the specified directory, recursively downloading the entire specified URL path.

That command also includes -e robots=off, which ignores restrictions in the robots.txt file. In general, it’s a good idea to disable robots.txt to prevent abridged downloads.

Other wget Flags

In addition to the flags above, this selected handful of wget’s flags are the most useful:

Controlling the download

  • wget -X /absolute/path/to/directory will exclude a specific directory on the remote server.
  • wget -nH removes the hostname directories. Remember, the hostname is the part of the URL that contains the domain name and ends in a TLD like “.com.” For example, the folder named “www.w3.org” in our previous example would be skipped, starting the download with the “History” directory instead.
  • wget --cut-dirs=# skips the specified number of directories down the URL before starting to download files. For example, -nH --cut-dirs=1  would change the specified path of “ftp.xemacs.org/pub/xemacs/” into simply “/xemacs/,” reducing the number of empty parent directories in the local download.
  • wget -R index.html/wget --reject index.html will skip any files matching the specified file name. In this case it will exclude all the index files. The * character can be used as a wildcard, like “*.png,” which would skip all files with the PNG extension.
  • wget -i file specifies target URLs from an input file. The input file must be an HTML file or be parsed as HTML with the additional flag --force-html
  • wget -nc/wget --no-clobber will not overwrite files that already exist in the destination.
  • wget -c/wget --continue will continue downloads of partially downloaded files.
  • wget -t 10 will try to download the resource up to 10 times before failing.

Adjusting the level of logging

  • wget -d enables debugging output.
  • wget -o path/to/log.txt enables logging output to the specified directory instead of displaying the log-in standard output.
  • wget -q turns off all of wget’s output, including error messages.
  • wget -v explicitly enables wget’s default of verbose output.
  • wget --no-verbose turns off log messages but displays error messages.

Conclusion

While that should cover the majority of wget use cases, the downloader is capable of much more. For a full description of wget’s capabilities, you can review wget’s GNU man page online.


[출처] https://www.maketecheasier.com/install-wget-mac/


?

  1. How to completely Uninstall Coda

    Date2017.10.24 CategoryEtc Byhooni Views2187
    Read More
  2. How to Install and Use wget on Mac

    Date2020.09.03 CategorySystem/OS Byhooni Views1288
    Read More
  3. How to Setup an Email Server on CentOS 7

    Date2018.04.05 CategorySystem/OS Byhooni Views2790
    Read More
  4. How to Test SMTP AUTH using Telnet

    Date2018.04.05 CategoryDevelop Byhooni Views1343
    Read More
  5. HTTP 프로토콜 (브라우저와 웹서버 간의 통신)

    Date2003.04.23 CategorySystem/OS Byhooni Views48251
    Read More
  6. HTTPS와 SSL 인증서

    Date2014.03.11 CategorySystem/OS Byhooni Views7548
    Read More
  7. iOS 에서 쓸만한 오프라인 구글지도 찾기

    Date2014.01.06 CategoryEtc Byhooni Views16038
    Read More
  8. IoT가 만드는 미래와 플랫폼 경쟁력

    Date2014.09.23 CategoryEtc Byhooni Views0
    Read More
  9. IPR 특허 관련

    Date2015.04.28 CategoryEtc Byhooni Views0
    Read More
  10. iptime 공유기 해킹 기술문서

    Date2015.01.01 CategorySystem/OS Byhooni Views1941
    Read More
  11. ISMS 인증기준 – 정보보호대책 (시스템개발보안)

    Date2016.12.01 CategoryEtc Byhooni Views1327
    Read More
  12. IT감사 기법 시험

    Date2017.06.14 CategoryEtc Byhooni Views1423
    Read More
  13. JSON, BSON 변환

    Date2013.04.23 CategoryDevelop Byhooni Views11814
    Read More
  14. Laravel 5 Failed opening required bootstrap/../vendor/autoload.php

    Date2018.01.24 CategoryDevelop Byhooni Views1662
    Read More
  15. Mac OS X - Apache+PHP+MySQL 환경 서버

    Date2013.04.25 CategorySystem/OS Byhooni Views31629
    Read More
  16. Mac OS 에 Jenkins 설치하기 (Homebrew)

    Date2017.03.15 CategoryDevelop Byhooni Views8122
    Read More
Board Pagination Prev 1 2 3 4 5 ... 74 Next
/ 74