- 💄 Как установить и использовать Wget на Mac
- Установка Wget через Xcode
- Установка Wget через Homebrew
- Как использовать Wget на Mac
- Mac OS X Install wget Network Downloader Utility
- Method #1: Install wget using brew (recommended method)
- Install Homebrew
- Install wget
- Use wget
- Method #2: Install wget using source code (recommended for advanced users only)
- Step #1: Download gnu/wget source code
- Step #2: Extract files
- Step #3: Configure, Compile and Install GNU/wget on OS X
- Find out wget location on OS X
- How do I use wget command?
- How do I update installed gnu/wget on OS X?
- A note about installing wget on macOS Sierra using source code
- How to Install and Use wget on Mac
- What is wget (And What It’s Used For)?
- How to Install wget on Mac
- 1. Download and Install Homebrew
- 2. Install wget From the Command Line
- How to Use wget to Download Web Resources
- How to Download a Recursive Directory
- Using Additional Flags with wget
- Control How wget Will Download Resources
- Adjust the Level of Logging
- Conclusion
💄 Как установить и использовать Wget на Mac
wget – это надежное приложение командной строки для загрузки ресурсов, указанных в URL.
Он был разработан для превосходной работы даже при плохом соединении.
Его уникальная особенность по сравнению с curl, который поставляется, например, с macOS, заключается в том, что он неинтерактивен, поэтому может работать в фоновом режиме.
Есть 2 способа установить wget: через Xcode или Homebrew, и я расскажу об обоих методах, так как не все используют Xcode или Homebrew.
Установка Wget через Xcode
Установка wget на Mac через XCode требует сборки инструмента из исходного кода, и шаги одинаковы для всех версий Mac:
Сначала установите Xcode через iTunes, а затем установите инструменты командной строки Xcode с помощью команды:
Загрузите исходный код wget, используя curl:
Извлеките и перейдите в папку и выполните команду configure:
Выполните make и и протестируйте wget:
Если при запуске команды configure выдается ошибка, запустите ее с флагом SSL, например:
Не забудьте удалить ненужные файлы после завершения установки.
Установка Wget через Homebrew
Homebrew – это менеджер пакетов для OS X, который значительно упрощает установку и управление приложениями для пользователей Mac.
Есть альтернативы, такие как Fink и MacPorts, но я предпочитаю использовать Homebrew.
Установите Homebrew с помощью следующей команды,команда также установит инструменты командной строки Xcode, если они еще не установлены:
Затем установите клиент для загрузки из командной строки wget.
Как использовать Wget на Mac
Если URL-адрес файла или каталога общедоступен, его можно загрузить, а файлы можно загружать отдельно или рекурсивно при загрузке каталогов.
Скачивание одного файла
Синтаксис прост. команда wget, -X для указания пути к файлу (если вы не хотите сохранить загруженный контент в текущий рабочий каталог) и публичная ссылка.
Источник
Mac OS X Install wget Network Downloader Utility
I recently learned that “wget” can continue getting a partially-downloaded (resume download) file. I am unable to find wget command on Mac OS X. How do I install install wget on Mac OS X (Mountain Lion/ Mavericks / Snow Leopard / Big Sur)? How can I install wget in Mac OS X without 3rd-party repo such as Homebrew or MacPorts?
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | macOS and xcode |
Est. reading time | 6 minutes |
You can install the latest version of GNU/wget and many other open source software without using Homebrew or MacPorts. The steps are as follows to install wget on macOS Sierra using either Homebrew or source code:
- Easy method #1: Install Homebrew and type command ‘ brew install wget ‘ on macOS Sierra.
- Source code method #2:
- Download, compile and install OpenSSL
- Download, compile and install wget on macOS Sierra
Let use see both methods in detailed.
Method #1: Install wget using brew (recommended method)
Trust me this is the best and easy method to install wget using Homebrew. First install Homebrew on macOS.
Install Homebrew
$ /usr/bin/ruby -e «$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)»
Install wget
$ brew install wget
Sample outputs:
Use wget
$ /usr/local/bin/wget url
$ /usr/local/bin/wget url/file.tar.gz
$ /usr/local/bin/wget https://www.cyberciti.biz/
That is all, and you need to stop reading the rest. Please note that the rest of the following tutorial covers wget command installation using the source code method.
Method #2: Install wget using source code (recommended for advanced users only)
You need to install a free app called Xcode. It includes command line development tools such as gnu/gcc and friends. See how to install GCC Compiler with Xcode for more information.
Fig.01: Install gcc compiler on Mac OS X
Step #1: Download gnu/wget source code
Use curl command as follows to download the latest gnu/wget from the official project site. Open the Terminal and than type the following commands:
$ cd /tmp
$ curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
$ ls -l
Sample outputs:
Fig.02: Downloading wget source code with the curl utility
Step #2: Extract files
Use the tar command to extract files on OS X as follows:
$ tar xvf wget-1.15.tar.gz
Sample outputs:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Step #3: Configure, Compile and Install GNU/wget on OS X
First, cd to the wget-1.15 directory using cd command:
$ cd wget-1.15
To configure wget, enter:
$ ./configure —with-ssl=openssl
Sample outputs:
To compile wget on OS X, enter:
$ make
Sample outputs:
To install wget, enter:
$ sudo make install
Find out wget location on OS X
By default wget will be installed at the /usr/local/bin/wget . You can use the whereis utility (or type -a) to check the wget location, enter:
$ whereis wget
OR
$ type -a wget
If you do not see output, edit $HOME/.bash_profile or $HOME/.bashrc and add/edit/append PATH as follows:
export PATH=$
Save and close the file.
How do I use wget command?
The basic syntax is:
wget url
wget http://www.cyberciti.biz/
wget ftp://url/
To see wget version, type:
$ wget —version
Sample outputs:
Installed wget on macOS Sierra
How do I update installed gnu/wget on OS X?
Warning : The following method only works if you installed gnu/wget earlier using source code based method as described above. Do not use the following method if you installed wget using Homebrew or MacPorts.
A note about installing wget on macOS Sierra using source code
You need to first install the latest version of openssl:
### Step #1: Grab and install latest openssl version 1.19.1 using source code ###
$ cd /tmp/
$ curl -O https://www.openssl.org/source/openssl-1.1.0e.tar.gz
$ tar -zxvf openssl-1.1.0e.tar.gz
$ cd openssl-1.1.0e
$ ./config
$ make
$ sudo make install
Finally install wget using the following method:
### Step #2: Grab and install wget version 1.19.1 using source code ###
$ cd /tmp
$ curl -O http://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.gz
$ tar -zxvf wget-1.19.1.tar.gz
$ cd wget-1.19.1
$ export OPENSSL_CFLAGS=»-I/usr/local/include»
$ export OPENSSL_LIBS=»-L/usr/local/lib -lssl -lcrypto -lz»
$ ./configure —with-ssl=openssl
$ make
$ sudo make install
$ /usr/local/bin/wget url
See also
I recommend the following resources for usage and examples on both wget and curl commands:
And there you have it, gnu/wget installed from directly source code without using 3rd party repos.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
Worked like magic on my OSX 10.6.8 ! More PLZ!
I don’t use a MAC but would like to thank and congratulate the poster on his excellent and comprehensive reply.. Great work!
I was inspired so i looked up something else – today successfully compiled Nmap from source. ( link – nmap.org/download.html#source )
I also tried mtr, but that failed. May look into it later.
This also on OSX 10.6.8 of course.
Awesome, thanks so much for helping!…
Alternatively, one could have Macports (https://www.macports.org/) installed and simply install wget via the CLI:
Then create a link to wget, and use it from the CLI like on any other posix box:
It came to me with below?
sudo ln -s /opt/local/bin/wget /usr/bin/wget
ln: /usr/bin/wget: Operation not permitted
tkx302:rgtdata ye.liu$
curl can also resume a partially downloaded file, even on mac os x. I see why you need wget for this…
just do:
$ curl -C –
A better way would be to install Homebrew and then install wget through it.
Why is this way better than any of the others suggested?
It only take 2 minutes provided that you *trust Homebrew devs* not to install backdoor in GNU wget. Having said that I used the ‘brew install wget’ method. As it was very easy and I am lazy af. I trust Homebrew devs 🙂 YMMV.
configure: error: in `/Users/blue/wget-1.16.3′:
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see .
See `config.log’ for more details
blue:wget-1.16.3 blue$ make
There seems to be no Makefile in this directory.
You must run ./configure before running ‘make’.
make: *** [abort-due-to-no-makefile] Error 1
I can’t use make… I even used just ./configure but same result, please help…
I have the same issue here, still can’t figure it out how to do this. Any luck with “no Makefile” ?
Blue phoenix and Jeannie, I have updated the page to install latest version of wget 1.19.1 on macOS Sierra. Check it out and let me know.
I’m late to this party but I want to sincerely thank the poster for this, very much. It’s unbelievable how difficult it is to find such basic information like this anymore. Now, it’s all one after the other, parroting the “use homebrew” BS. Anyway this is an excellent, concise, incredibly useful guide, thank you.
(And, soapbox: sorry for being old-school and with decades of an InfoSec background drilled into me, but there is something very decidedly fishy about Homebrew. In my opinion, anyone who relies on “package managers” to install everything, basically giving the keys to their system to some anonymous “developers”, is cognitively deficient. Which unfortunately seems to be most these days. Homebrew is easily the worst and most suspicious. It came out of nowhere several years back and has been relentlessly pushed ever since. Relentlessly. There is something absolutely dirty behind it, beyond a doubt. Those with eyes to see and minds to think will know exactly what I’m saying, and will have come to the same thinking and conclusions long ago. The rest: back to sleep…)
Источник
How to Install and Use wget on Mac
There are plenty of ways you can download resources from the web. Other than your browser, you can also use a tool like wget to download resources from the Web while you do something else. In this article, we show you how to download and use wget on Mac.
Also read: How to Use Wget to Download Websites to Your PC
What is wget (And What It’s Used For)?
For the unaware, wget is an open-source non-interactive command-line utility to help you download resources from a specified URL. Because it is non-interactive, wget can work in the background or before you even log in.
It’s a project by the GNU team, and it’s great if you have a poor Internet connection. This means it’s robust in otherwise non-optimal conditions.
Once you install wget, you’ll run commands and specify a destination for your files. We show you how to do this next.
How to Install wget on Mac
Before you install wget, you need a package manager. While wget doesn’t ship with macOS, you can download and install it using Homebrew – the best Mac package manager available.
1. Download and Install Homebrew
To install Homebrew, first open a Terminal window and execute the following command:
This uses the curl command to download files that ship within the pre-installed Ruby installation on macOS.
Once you press Enter to run the command, the installer will give you explicit details on what will happen.
After you confirm, the installer will run.
2. Install wget From the Command Line
Next up, we want to use Homebrew to install wget. From the Terminal again, run:
The installer will give you live progress updates, and there’s little you need to do here. The process is straightforward and automated. Though, if you already have Homebrew installed, be sure to run brew update to get the latest copies of all your formulae.
Once you see a new prompt within your Terminal, you’re ready to use wget on Mac to download resources.
Also read: How to Run a Python Script on Mac
How to Use wget to Download Web Resources
To download a remote resource from a URL using wget, you’ll want to use the following structure:
That will save the file specified in the URL to the location specified on your machine.
If you exclude the -O “flag,” your download location will the the current working directory.
For example, we want to download a webpage to the Downloads folder:
Though, to do the same without the -O flag, we’d need to change the directory ( cd downloads ) before we run wget:
You’ll get the full details on the download progress, although, with how quick wget is, this information is akin to a summary of the download rather than real-time updates.
How to Download a Recursive Directory
To download an entire directory tree with wget, you need to use the -r / —recursive and -np / —no-parent flags:
This will cause wget to follow any links found on the documents within the specified directory. From there it will perform a recursive download of the entire specified URL path.
Also, note the -e robots=off command. This ignores restrictions in the robots.txt file. In general, it’s a good idea to disable robots.txt to prevent abridged downloads.
Using Additional Flags with wget
You’ll find that wget is a flexible tool, as it uses a number of other additional flags. This is great if you have specific requirements for your download.
Let’s take a look at two areas in our focus on controlling the download process and creating logs.
Control How wget Will Download Resources
There are many flags to help you set up the download process. Here are just a few of the most useful:
- wget -X /absolute/path/to/directory will exclude a specific directory on the remote server.
- wget -nH removes the “hostname” directories. In other words, it skips over the primary domain name. For example, wget would skip the www.w3.org folder in the previous example and start 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/” and reduce 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 asterisk (*) is a wildcard, such as “*.png”. This would skip all files with the PNG extension.
- wget -i file specifies target URLs from an input file. This input file must be in HTML format, or you’ll need to use the —force-html flag to parse the 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.
wget can do more than control the download process, as you can also create logs for future reference.
Adjust the Level of Logging
You can also consider the following flags as a partial way to control the output you receive when using wget.
- 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 messag\es but displays error messages.
You would often want to know what’s happening during a download, so you may not use these flags as much as others. Still, if you have a big batch of downloads and want to make sure you can fix any issues, having a log or lack of output is a valid approach.
Also read: How to Add and Remove Kexts from macOS
Conclusion
While you could use your browser or another GUI to download web pages and other resources, you can save time with the command line. A tool such as wget is powerful – more so than your browser – and is snappy, too. For a full description of wget’s capabilities, you can review wget’s GNU man page.
If you find that wget isn’t working for you, it might be time to diagnose a problem with your Wi-Fi connection. Will you use wget on Mac to download web resources? Share your thoughts in the comments section below!
Tom Rankin is a quality content writer for WordPress, tech, and small businesses. When he’s not putting fingers to keyboard, he can be found taking photographs, writing music, playing computer games, and talking in the third-person.
Источник