How To Install And Use Wget On Mac OS X To Implement File Download Breakpoint Resume

Wget is an open source file download tool for both Windows, Linux and Mac OS. It can continue get a partially downloaded file which is called breakpoint resume. This article will tell you how to install wget on mac os x and how to use it to implement file download breakpoint resume to continue download a partially download file.

1. Use HomeBrew To Install Wget On Mac OS X.

Open a terminal and run $ brew install wget command in it. But if you find the command line console stuck for a long time, you can press control + c, and then press enter key to break the stuck. Now you will get wget download and install process output information in the console like below.

$ brew install wget
Updating Homebrew...

^C
==> Installing dependencies for wget: gettext, libunistring, libidn2 and openssl
==> Installing wget dependency: gettext
==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.8.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/af/afc6a6120632b98d58b11fab82ae5e081206b89684dd948abf2d29caeb813ffd?__gda__=exp=1560673282~hmac=0b4d64b6a4c1d53a887dd6f0368402708f5
######################################################################## 100.0%
==> Pouring gettext-0.19.8.1.mojave.bottle.tar.gz
==> Caveats
gettext is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD gettext library & some software gets confused if both are in the library path.

If you need to have gettext first in your PATH run:
  echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

For compilers to find gettext you may need to set:
  export LDFLAGS="-L/usr/local/opt/gettext/lib"
  export CPPFLAGS="-I/usr/local/opt/gettext/include"

==> Summary
?  /usr/local/Cellar/gettext/0.19.8.1: 1,935 files, 16.9MB
==> Installing wget dependency: libunistring
==> Downloading https://homebrew.bintray.com/bottles/libunistring-0.9.10.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/1d/1d0c8e266acddcebeef3d9f6162d6f7fa0b193f5f71837174fb2ef0b39d324f3?__gda__=exp=1560673292~hmac=a0bae8d39d8884125107a55921a7f0a4979
######################################################################## 100.0%
==> Pouring libunistring-0.9.10.mojave.bottle.tar.gz
?  /usr/local/Cellar/libunistring/0.9.10: 54 files, 4.4MB
==> Installing wget dependency: libidn2
==> Downloading https://homebrew.bintray.com/bottles/libidn2-2.2.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/1b/1bddaa4464445f918c144762158254ac72edbc1f7328467a259a03aeb7bd547d?__gda__=exp=1560673297~hmac=61379198b3bc35dbdd1c5911d858694356c
######################################################################## 100.0%
==> Pouring libidn2-2.2.0.mojave.bottle.tar.gz
?  /usr/local/Cellar/libidn2/2.2.0: 70 files, 700.9KB
==> Installing wget dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2r.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/c1/c1f8c06740398325c7028213b20b18c5de39763fbc81e5819c78a06ee0621170?__gda__=exp=1560673301~hmac=d29a167de9e75b72c06bcd1ecee8a3466f4
######################################################################## 100.0%
==> Pouring openssl-1.0.2r.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> Summary
?  /usr/local/Cellar/openssl/1.0.2r: 1,795 files, 12.1MB
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.20.3_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/96/96a58c26308afae033e6d6325e7af3f20618b4ca84f2d265ba3ca16a5eae7e65?__gda__=exp=1560673310~hmac=1580578eb65d832423b6e9394b9f90abb88
######################################################################## 100.0%
==> Pouring wget-1.20.3_1.mojave.bottle.tar.gz
?  /usr/local/Cellar/wget/1.20.3_1: 49 files, 4.0MB
==> `brew cleanup` has not been run in 30 days, running now...
Error: Cask adoptopenjdk8 exists in multiple taps:
  homebrew/cask-versions/adoptopenjdk8
  caskroom/versions/adoptopenjdk8

2. Find Out Where Wget Is Installed.

You can run command type -a wget in a terminal to find out where wget is installed in your mac os.

$ type -a wget
wget is /usr/local/bin/wget

3. How To Use Wget.

3.1 Get Web Page Content.

Run $ wget page_url in terminal will get and save the requested url page content in a local file. You will see below output in terminal. The page_url can be a http, https or ftp protocol format url.

$ wget www.dev2qa.com
--2019-06-16 18:19:15--  http://www.dev2qa.com/
Resolving www.dev2qa.com (www.dev2qa.com)... 104.27.146.13, 104.27.147.13
Connecting to www.dev2qa.com (www.dev2qa.com)|104.27.146.13|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.dev2qa.com/ [following]
--2019-06-16 18:19:16--  https://www.dev2qa.com/
Connecting to www.dev2qa.com (www.dev2qa.com)|104.27.146.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html                                       [    <=>                                                                                       ] 112.12K   122KB/s    in 0.9s    

2019-06-16 18:19:19 (122 KB/s) - ‘index.html’ saved [114815]

In above example, the index.html file is saved in the directory where you run the wget command. You can run command ls -l in terminal to see the saved index.html file.

$ ls -l
total 232
......
-rw-r--r--   1 songzhao  staff  114815 Jun 16 18:19 index.html
......

3.2 Show Current Wget Version.

$ wget --version
GNU Wget 1.20.3 built on darwin18.6.0.
......

4. How To Implement Resume Download Use Wget.

If you want to resume download a partially downloaded file use wget, you can follow below steps.

  1. Open a terminal and run cd command to go to the previous partially downloaded file saved directory.
  2. Run command line wget -c file_url, or wget -continue file_url in the terminal under above directory, the -c or -continue parameter for wget command will tell wget to continue download previous file from the offset of the exist file size. If the file_url is same, then the downloaded local file name is same.

References

  1. Pass Download Popup Dialog Using Selenium Webdriver And WGet

Subscribe to receive more programming tricks.

We don’t spam!

Subscribe to receive more programming tricks.

We don’t spam!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.