1WGET2(1) GNU Wget2 2.0.0 WGET2(1)
2
3
4
6 Wget2 - a recursive metalink/file/website downloader.
7
9 wget2 [options]... [URL]...
10
12 GNU Wget2 is a free utility for non-interactive download of files from
13 the Web. It supports HTTP and HTTPS protocols, as well as retrieval
14 through HTTP(S) proxies.
15
16 Wget2 is non-interactive, meaning that it can work in the background,
17 while the user is not logged on. This allows you to start a retrieval
18 and disconnect from the system, letting Wget2 finish the work. By con‐
19 trast, most of the Web browsers require constant user’s presence, which
20 can be a great hindrance when transferring a lot of data.
21
22 Wget2 can follow links in HTML, XHTML, CSS, RSS, Atom and sitemap files
23 to create local versions of remote web sites, fully recreating the di‐
24 rectory structure of the original site. This is sometimes referred to
25 as recursive downloading. While doing that, Wget2 respects the Robot
26 Exclusion Standard (/robots.txt). Wget2 can be instructed to convert
27 the links in downloaded files to point at the local files, for offline
28 viewing.
29
30 Wget2 has been designed for robustness over slow or unstable network
31 connections; if a download fails due to a network problem, it will keep
32 retrying until the whole file has been retrieved. If the server sup‐
33 ports partial downloads, it may continue the download from where it
34 left off.
35
37 Option Syntax
38 Every option has a long form and sometimes also a short one. Long op‐
39 tions are more convenient to remember, but take time to type. You may
40 freely mix different option styles. Thus you may write:
41
42 wget2 -r --tries=10 https://example.com/ -o log
43
44 The space between the option accepting an argument and the argument may
45 be omitted. Instead of -o log you can write -olog.
46
47 You may put several options that do not require arguments together,
48 like:
49
50 wget2 -drc <URL>
51
52 This is equivalent to:
53
54 wget2 -d -r -c <URL>
55
56 Since the options can be specified after the arguments, you may termi‐
57 nate them with --. So the following will try to download URL -x, re‐
58 porting failure to log:
59
60 wget2 -o log -- -x
61
62 The options that accept comma-separated lists all respect the conven‐
63 tion that prepending --no- clears its value. This can be useful to
64 clear the .wgetrc settings. For instance, if your .wgetrc sets ex‐
65 clude-directories to /cgi-bin, the following example will first reset
66 it, and then set it to exclude /priv and /trash. You can also clear
67 the lists in .wgetrc.
68
69 wget2 --no-exclude-directories -X /priv,/trash
70
71 Most options that do not accept arguments are boolean options, so named
72 because their state can be captured with a yes-or-no (“boolean”) vari‐
73 able. A boolean option is either affirmative or negative (beginning
74 with --no-). All such options share several properties.
75
76 Affirmative options can be negated by prepending the --no- to the op‐
77 tion name; negative options can be negated by omitting the --no- pre‐
78 fix. This might seem superfluous - if the default for an affirmative
79 option is to not do something, then why provide a way to explicitly
80 turn it off? But the startup file may in fact change the default. For
81 instance, using timestamping = on in .wgetrc makes Wget2 download up‐
82 dated files only. Using --no-timestamping is the only way to restore
83 the factory default from the command line.
84
85 Basic Startup Options
86 -V, --version
87 Display the version of Wget2.
88
89 -h, --help
90 Print a help message describing all of Wget2’s command-line options.
91
92 -b, --background
93 Go to background immediately after startup. If no output file is spec‐
94 ified via the -o, output is redirected to wget-log.
95
96 -e, --execute=command
97 Execute command as if it were a part of .wgetrc. A command thus in‐
98 voked will be executed after the commands in .wgetrc, thus taking
99 precedence over them. If you need to specify more than one wgetrc com‐
100 mand, use multiple instances of -e.
101
102 --hyperlink
103 Hyperlink names of downloaded files so that they can opened from the
104 terminal by clicking on them. Only a few terminal emulators currently
105 support hyperlinks. Enable this option if you know your terminal sup‐
106 ports hyperlinks.
107
108 Logging and Input File Options
109 -o, --output-file=logfile
110 Log all messages to logfile. The messages are normally reported to
111 standard error.
112
113 -a, --append-output=logfile
114 Append to logfile. This is the same as -o, only it appends to logfile
115 instead of overwriting the old log file. If logfile does not exist, a
116 new file is created.
117
118 -d, --debug
119 Turn on debug output, meaning various information important to the de‐
120 velopers of Wget2 if it does not work properly. Your system adminis‐
121 trator may have chosen to compile Wget2 without debug support, in which
122 case -d will not work. Please note that compiling with debug support
123 is always safe, Wget2 compiled with the debug support will not print
124 any debug info unless requested with -d.
125
126 -q, --quiet
127 Turn off Wget2’s output.
128
129 -v, --verbose
130 Turn on verbose output, with all the available data. The default out‐
131 put is verbose.
132
133 -nv, --no-verbose
134 Turn off verbose without being completely quiet (use -q for that),
135 which means that error messages and basic information still get print‐
136 ed.
137
138 --report-speed=type
139 Output bandwidth as type. The only accepted values are bytes (which is
140 set by default) and bits. This option only works if --progress=bar is
141 also set.
142
143 -i, --input-file=file
144 Read URLs from a local or external file. If - is specified as file,
145 URLs are read from the standard input. Use ./- to read from a file
146 literally named -.
147
148 If this function is used, no URLs need be present on the command line.
149 If there are URLs both on the command line and in an input file, those
150 on the command lines will be the first ones to be retrieved. file is
151 expected to contain one URL per line, except one of the –force- options
152 specifies a different format.
153
154 If you specify --force-html, the document will be regarded as HTML. In
155 that case you may have problems with relative links, which you can
156 solve either by adding <base href="url"> to the documents or by speci‐
157 fying --base=url on the command line.
158
159 If you specify --force-css, the document will be regarded as CSS.
160
161 If you specify --force-sitemap, the document will be regarded as XML
162 sitemap.
163
164 If you specify --force-atom, the document will be regarded as Atom
165 Feed.
166
167 If you specify --force-rss, the document will be regarded as RSS Feed.
168
169 If you specify --force-metalink, the document will be regarded as Met‐
170 alink description.
171
172 If you have problems with relative links, you should use --base=url on
173 the command line.
174
175 -F, --force-html
176 When input is read from a file, force it to be treated as an HTML file.
177 This enables you to retrieve relative links from existing HTML files on
178 your local disk, by adding “” to HTML, or using the –base command-line
179 option.
180
181 --force-css
182 Read and parse the input file as CSS. This enables you to retrieve
183 links from existing CSS files on your local disk. You will need –base
184 to handle relative links correctly.
185
186 --force-sitemap
187 Read and parse the input file as sitemap XML. This enables you to re‐
188 trieve links from existing sitemap files on your local disk. You will
189 need –base to handle relative links correctly.
190
191 --force-atom
192 Read and parse the input file as Atom Feed XML. This enables you to
193 retrieve links from existing sitemap files on your local disk. You
194 will need –base to handle relative links correctly.
195
196 --force-rss
197 Read and parse the input file as RSS Feed XML. This enables you to re‐
198 trieve links from existing sitemap files on your local disk. You will
199 need –base to handle relative links correctly.
200
201 --force-metalink
202 Read and parse the input file as Metalink. This enables you to re‐
203 trieve links from existing Metalink files on your local disk. You will
204 need –base to handle relative links correctly.
205
206 -B, --base=URL
207 Resolves relative links using URL as the point of reference, when read‐
208 ing links from an HTML file specified via the -i/–input-file option
209 (together with a –force... option, or when the input file was fetched
210 remotely from a server describing it as HTML, CSS, Atom or RSS). This
211 is equivalent to the presence of a “BASE” tag in the HTML input file,
212 with URL as the value for the “href” attribute.
213
214 For instance, if you specify https://example.com/bar/a.html for URL,
215 and Wget2 reads ../baz/b.html from the input file, it would be resolved
216 to https://example.com/baz/b.html.
217
218 --config=FILE
219 Specify the location of configuration files you wish to use. If you
220 specify more than one file, either by using a comma-separated list or
221 several --config options, these files are read in left-to-right order.
222 The files given in $SYSTEM_WGET2RC and ($WGET2RC or ~/.wget2rc) are
223 read in that order and then the user-provided config file(s). If set,
224 $WGET2RC replaces ~/.wget2rc.
225
226 --no-config empties the internal list of config files. So if you want
227 to prevent reading any config files, give –no-config on the command
228 line.
229
230 --no-config followed by --config=file just reads file and skips reading
231 the default config files.
232
233 Wget will attempt to tilde-expand filenames written in the configura‐
234 tion file on supported platforms. To use a file that starts with the
235 character literal `~', use “./~” or an absolute path.
236
237 --rejected-log=logfile [Not implemented yet]
238 Logs all URL rejections to logfile as comma separated values. The val‐
239 ues include the reason of rejection, the URL and the parent URL it was
240 found in.
241
242 --local-db
243 Enables reading/writing to local database files (default: on).
244
245 These are the files for --hsts, --hpkp, --ocsp, etc.
246
247 With --no-local-db you can switch reading/writing off, e.g. useful for
248 testing.
249
250 This option does not influence the reading of config files.
251
252 --stats-dns=[FORMAT:]FILE
253 Save DNS stats in format FORMAT, in file FILE.
254
255 FORMAT can be human or csv. - is shorthand for stdout and h is short‐
256 hand for human.
257
258 The CSV output format is
259
260 Hostname,IP,Port,Duration
261
262 `Duration` is given in milliseconds.
263
264 --stats-tls=[FORMAT:]FILE
265 Save TLS stats in format FORMAT, in file FILE.
266
267 FORMAT can be human or csv. - is shorthand for stdout and h is short‐
268 hand for human.
269
270 The CSV output format is
271
272 Hostname,TLSVersion,FalseStart,TFO,Resumed,ALPN,HTTPVersion,Certifi‐
273 cates,Duration
274
275 `TLSVersion` can be 1,2,3,4,5 for SSL3, TLS1.0, TLS1.1, TLS1.2 and TLS1.3. -1 means 'None'.
276
277 `FalseStart` whether the connection used TLS False Start. -1 if not applicable.
278
279 `TFO` whether the connection used TCP Fast Open. -1 is TFO was disabled.
280
281 `Resumed` whether the TLS session was resumed or not.
282
283 `ALPN` is the ALPN negotiation string.
284
285 `HTTPVersion` is 0 for HTTP 1.1 and 1 is for HTTP 2.0.
286
287 `Certificates` is the size of the server's certificate chain.
288
289 `Duration` is given in milliseconds.
290
291 --stats-ocsp=[FORMAT:]FILE
292 Save OCSP stats in format FORMAT, in file FILE.
293
294 FORMAT can be human or csv. - is shorthand for stdout and h is short‐
295 hand for human.
296
297 The CSV output format is
298
299 Hostname,Stapling,Valid,Revoked,Ignored
300
301 `Stapling` whether an OCSP response was stapled or not.
302
303 `Valid` how many server certificates were valid regarding OCSP.
304
305 `Revoked` how many server certificates were revoked regarding OCSP.
306
307 `Ignored` how many server certificates had been ignored or OCSP responses missing.
308
309 --stats-server=[FORMAT:]FILE
310 Save Server stats in format FORMAT, in file FILE.
311
312 FORMAT can be human or csv. - is shorthand for stdout and h is short‐
313 hand for human.
314
315 The CSV output format is
316
317 Hostname,IP,Scheme,HPKP,NewHPKP,HSTS,CSP
318
319 `Scheme` 0,1,2 mean `None`, `http`, `https`.
320
321 `HPKP` values 0,1,2,3 mean 'No HPKP', 'HPKP matched', 'HPKP doesn't match', 'HPKP error'.
322
323 `NewHPKP` whether server sent HPKP (Public-Key-Pins) header.
324
325 `HSTS` whether server sent HSTS (Strict-Transport-Security) header.
326
327 `CSP` whether server sent CSP (Content-Security-Policy) header.
328
329 --stats-site=[FORMAT:]FILE
330 Save Site stats in format FORMAT, in file FILE.
331
332 FORMAT can be human or csv. - is shorthand for stdout and h is short‐
333 hand for human.
334
335 The CSV output format is
336
337 ID,ParentID,URL,Status,Link,Method,Size,SizeDecompressed,Transfer‐
338 Time,ResponseTime,Encoding,Verification
339
340 `ID` unique ID for a stats record.
341
342 `ParentID` ID of the parent document, relevant for `--recursive` mode.
343
344 `URL` URL of the document.
345
346 `Status` HTTP response code or 0 if not applicable.
347
348 `Link` 1 means 'direkt link', 0 means 'redirection link'.
349
350 `Method` 1,2,3 mean GET, HEAD, POST request type.
351
352 `Size` size of downloaded body (theoretical value for HEAD requests).
353
354 `SizeDecompressed` size of decompressed body (0 for HEAD requests).
355
356 `TransferTime` ms between start of request and completed download.
357
358 `ResponseTime` ms between start of request and first response packet.
359
360 `Encoding` 0,1,2,3,4,5 mean server side compression was 'identity', 'gzip', 'deflate', 'lzma/xz', 'bzip2', 'brotli', 'zstd', 'lzip'
361
362 `Verification` PGP verification status. 0,1,2,3 mean 'none', 'valid', 'invalid', 'bad', 'missing'.
363
364 Download Options
365 --bind-address=ADDRESS
366 When making client TCP/IP connections, bind to ADDRESS on the local ma‐
367 chine. ADDRESS may be specified as a hostname or IP address. This op‐
368 tion can be useful if your machine is bound to multiple IPs.
369
370 --bind-interface=INTERFACE
371 When making client TCP/IP connections, bind to INTERFACE on the local
372 machine. INTERFACE may be specified as the name for a Network Inter‐
373 face. This option can be useful if your machine has multiple Network
374 Interfaces. However, the option works only when wget2 is run with ele‐
375 vated privileges (On GNU/Linux: root / sudo or sudo setcap
376 cap_net_raw+ep <path to wget|wget2>).
377
378 -t, --tries=number
379 Set number of tries to number. Specify 0 or inf for infinite retrying.
380 The default is to retry 20 times, with the exception of fatal errors
381 like “connection refused” or “not found” (404), which are not retried.
382
383 --retry-on-http-error=list
384 Specify a comma-separated list of HTTP codes in which Wget2 will retry
385 the download. The elements of the list may contain wildcards. If an
386 HTTP code starts with the character `!' it won’t be downloaded. This
387 is useful when trying to download something with exceptions. For exam‐
388 ple, retry every failed download if error code is not 404:
389
390 wget2 --retry-on-http-error=*,\!404 https://example.com/
391
392 Please keep in mind that “200” is the only forbidden code. If it is
393 included on the status list Wget2 will ignore it. The max. number of
394 download attempts is given by the --tries option.
395
396 -O, --output-document=file
397 The documents will not be written to the appropriate files, but all
398 will be concatenated together and written to file. If - is used as
399 file, documents will be printed to standard output, disabling link con‐
400 version. Use ./- to print to a file literally named -. To not get
401 Wget2 status messages mixed with file content, use -q in combination
402 with -O- (This is different to how Wget 1.x behaves).
403
404 Using -r or -p with -O may not work as you expect: Wget2 won’t just
405 download the first file to file and then download the rest to their
406 normal names: all downloaded content will be placed in file.
407
408 A combination with -nc is only accepted if the given output file does
409 not exist.
410
411 When used along with the -c option, Wget2 will attempt to continue
412 downloading the file whose name is passed to the option, irrespective
413 of whether the actual file already exists on disk or not. This allows
414 users to download a file with a temporary name alongside the actual
415 file.
416
417 Note that a combination with -k is only permitted when downloading a
418 single document, as in that case it will just convert all relative URIs
419 to external ones; -k makes no sense for multiple URIs when they’re all
420 being downloaded to a single file; -k can be used only when the output
421 is a regular file.
422
423 Compatibility-Note: Wget 1.x used to treat -O as analogous to shell re‐
424 direction. Wget2 does not handle the option similarly. Hence, the
425 file will not always be newly created. The file’s timestamps will not
426 be affected unless it is actually written to. As a result, both -c and
427 -N options are now supported in conjunction with this option.
428
429 -nc, --no-clobber
430 If a file is downloaded more than once in the same directory, Wget2’s
431 behavior depends on a few options, including -nc. In certain cases,
432 the local file will be clobbered, or overwritten, upon repeated down‐
433 load. In other cases it will be preserved.
434
435 When running Wget2 without -N, -nc, -r, or -p, downloading the same
436 file in the same directory will result in the original copy of file be‐
437 ing preserved and the second copy being named file.1. If that file is
438 downloaded yet again, the third copy will be named file.2, and so on.
439 (This is also the behavior with -nd, even if -r or -p are in effect.)
440 Use --keep-extension to use an alternative file naming pattern.
441
442 When -nc is specified, this behavior is suppressed, and Wget2 will
443 refuse to download newer copies of file. Therefore, ““no-clobber”” is
444 actually a misnomer in this mode - it’s not clobbering that’s prevented
445 (as the numeric suffixes were already preventing clobbering), but
446 rather the multiple version saving that’s prevented.
447
448 When running Wget2 with -r or -p, but without -N, -nd, or -nc, re-down‐
449 loading a file will result in the new copy simply overwriting the old.
450 Adding -nc will prevent this behavior, instead causing the original
451 version to be preserved and any newer copies on the server to be ig‐
452 nored.
453
454 When running Wget2 with -N, with or without -r or -p, the decision as
455 to whether or not to download a newer copy of a file depends on the lo‐
456 cal and remote timestamp and size of the file. -nc may not be speci‐
457 fied at the same time as -N.
458
459 A combination with -O/--output-document is only accepted if the given
460 output file does not exist.
461
462 Note that when -nc is specified, files with the suffixes .html or .htm
463 will be loaded from the local disk and parsed as if they had been re‐
464 trieved from the Web.
465
466 --backups=backups
467 Before (over)writing a file, back up an existing file by adding a .1
468 suffix to the file name. Such backup files are rotated to .2, .3, and
469 so on, up to backups (and lost beyond that).
470
471 -c, --continue
472 Continue getting a partially-downloaded file. This is useful when you
473 want to finish up a download started by a previous instance of Wget2,
474 or by another program. For instance:
475
476 wget2 -c https://example.com/tarball.gz
477
478 If there is a file named tarball.gz in the current directory, Wget2
479 will assume that it is the first portion of the remote file, and will
480 ask the server to continue the retrieval from an offset equal to the
481 length of the local file.
482
483 Note that you don’t need to specify this option if you just want the
484 current invocation of Wget2 to retry downloading a file should the con‐
485 nection be lost midway through. This is the default behavior. -c only
486 affects resumption of downloads started prior to this invocation of
487 Wget2, and whose local files are still sitting around.
488
489 Without -c, the previous example would just download the remote file to
490 tarball.gz.1, leaving the truncated tarball.gz file alone.
491
492 If you use -c on a non-empty file, and it turns out that the server
493 does not support continued downloading, Wget2 will refuse to start the
494 download from scratch, which would effectively ruin existing contents.
495 If you really want the download to start from scratch, remove the file.
496
497 If you use -c on a file which is of equal size as the one on the serv‐
498 er, Wget2 will refuse to download the file and print an explanatory
499 message. The same happens when the file is smaller on the server than
500 locally (presumably because it was changed on the server since your
501 last download attempt). Because “continuing” is not meaningful, no
502 download occurs.
503
504 On the other side of the coin, while using -c, any file that’s bigger
505 on the server than locally will be considered an incomplete download
506 and only “(length(remote) - length(local))” bytes will be downloaded
507 and tacked onto the end of the local file. This behavior can be desir‐
508 able in certain cases. For instance, you can use wget2 -c to download
509 just the new portion that’s been appended to a data collection or log
510 file.
511
512 However, if the file is bigger on the server because it’s been changed,
513 as opposed to just appended to, you’ll end up with a garbled file.
514 Wget2 has no way of verifying that the local file is really a valid
515 prefix of the remote file. You need to be especially careful of this
516 when using -c in conjunction with -r, since every file will be consid‐
517 ered as an “incomplete download” candidate.
518
519 Another instance where you’ll get a garbled file if you try to use -c
520 is if you have a lame HTTP proxy that inserts a “transfer interrupted”
521 string into the local file. In the future a “rollback” option may be
522 added to deal with this case.
523
524 Note that -c only works with HTTP servers that support the “Range”
525 header.
526
527 --start-pos=OFFSET
528 Start downloading at zero-based position OFFSET. Offset may be ex‐
529 pressed in bytes, kilobytes with the k' suffix, or megabytes with
530 them’ suffix, etc.
531
532 --start-pos has higher precedence over --continue. When --start-pos
533 and --continue are both specified, Wget2 will emit a warning then pro‐
534 ceed as if --continue was absent.
535
536 Server support for continued download is required, otherwise –start-pos
537 cannot help. See -c for details.
538
539 --progress=type
540 Select the type of the progress indicator you wish to use. Legal indi‐
541 cators are “dot” and “bar”.
542
543 It draws an ASCII progress bar graphics (a.k.a “thermometer” display)
544 indicating the status of retrieval. If the output is not a TTY, the
545 “dot” bar will be used by default.
546
547 Use --progress=dot to switch to the “dot” display. It traces the re‐
548 trieval by printing dots on the screen, each dot representing a fixed
549 amount of downloaded data.
550
551 The progress type can also take one or more parameters. The parameters
552 vary based on the type selected. Parameters to type are passed by ap‐
553 pending them to the type separated by a colon (:) like this:
554 --progress=type:parameter1:parameter2.
555
556 When using the dotted retrieval, you may set the style by specifying
557 the type as dot:style. Different styles assign different meaning to
558 one dot. With the “default” style each dot represents 1K, there are
559 ten dots in a cluster and 50 dots in a line. The “binary” style has a
560 more “computer”-like orientation: 8K dots, 16-dots clusters and 48 dots
561 per line (which makes for 384K lines). The “mega” style is suitable
562 for downloading large files, each dot represents 64K retrieved, there
563 are eight dots in a cluster, and 48 dots on each line (so each line
564 contains 3M). If “mega” is not enough then you can use the “giga”
565 style. Each dot represents 1M retrieved, there are eight dots in a
566 cluster, and 32 dots on each line (so each line contains 32M).
567
568 With --progress=bar, there are currently two possible parameters, force
569 and noscroll.
570
571 When the output is not a TTY, the progress bar always falls back to
572 “dot”, even if --progress=bar was passed to Wget2 during invocation.
573 This behaviour can be overridden and the “bar” output forced by using
574 the “force” parameter as --progress=bar:force.
575
576 By default, the bar style progress bar scroll the name of the file from
577 left to right for the file being downloaded if the filename exceeds the
578 maximum length allotted for its display. In certain cases, such as
579 with –progress=bar:force, one may not want the scrolling filename in
580 the progress bar. By passing the “noscroll” parameter, Wget2 can be
581 forced to display as much of the filename as possible without scrolling
582 through it.
583
584 Note that you can set the default style using the “progress” command in
585 .wgetrc. That setting may be overridden from the command line. For
586 example, to force the bar output without scrolling, use
587 –progress=bar:force:noscroll.
588
589 --force-progress
590 Force Wget2 to display the progress bar in any verbosity.
591
592 By default, Wget2 only displays the progress bar in verbose mode. One
593 may however, want Wget2 to display the progress bar on screen in con‐
594 junction with any other verbosity modes like –no-verbose or –quiet.
595 This is often a desired a property when invoking Wget2 to download sev‐
596 eral small/large files. In such a case, Wget2 could simply be invoked
597 with this parameter to get a much cleaner output on the screen.
598
599 This option will also force the progress bar to be printed to stderr
600 when used alongside the --output-file option.
601
602 -N, --timestamping
603 Turn on time-stamping.
604
605 --no-if-modified-since
606 Do not send If-Modified-Since header in -N mode. Send preliminary HEAD
607 request instead. This has only effect in -N mode.
608
609 --no-use-server-timestamps
610 Don’t set the local file’s timestamp by the one on the server.
611
612 By default, when a file is downloaded, its timestamps are set to match
613 those from the remote file. This allows the use of –timestamping on
614 subsequent invocations of Wget2. However, it is sometimes useful to
615 base the local file’s timestamp on when it was actually downloaded; for
616 that purpose, the –no-use-server-timestamps option has been provided.
617
618 -S, --server-response
619 Print the response headers sent by HTTP servers.
620
621 --spider
622 When invoked with this option, Wget2 will behave as a Web spider, which
623 means that it will not download the pages, just check that they are
624 there. For example, you can use Wget2 to check your bookmarks:
625
626 wget2 --spider --force-html -i bookmarks.html
627
628 This feature needs much more work for Wget2 to get close to the func‐
629 tionality of real web spiders.
630
631 -T seconds, --timeout=seconds
632 Set the network timeout to seconds seconds. This is equivalent to
633 specifying --dns-timeout, --connect-timeout, and --read-timeout, all at
634 the same time.
635
636 When interacting with the network, Wget2 can check for timeout and
637 abort the operation if it takes too long. This prevents anomalies like
638 hanging reads and infinite connects. The only timeout enabled by de‐
639 fault is a 900-second read timeout. Setting a timeout to 0 disables it
640 altogether. Unless you know what you are doing, it is best not to
641 change the default timeout settings.
642
643 All timeout-related options accept decimal values, as well as subsecond
644 values. For example, 0.1 seconds is a legal (though unwise) choice of
645 timeout. Subsecond timeouts are useful for checking server response
646 times or for testing network latency.
647
648 --dns-timeout=seconds
649 Set the DNS lookup timeout to seconds seconds. DNS lookups that don’t
650 complete within the specified time will fail. By default, there is no
651 timeout on DNS lookups, other than that implemented by system li‐
652 braries.
653
654 --connect-timeout=seconds
655 Set the connect timeout to seconds seconds. TCP connections that take
656 longer to establish will be aborted. By default, there is no connect
657 timeout, other than that implemented by system libraries.
658
659 --read-timeout=seconds
660 Set the read (and write) timeout to seconds seconds. The “time” of
661 this timeout refers to idle time: if, at any point in the download, no
662 data is received for more than the specified number of seconds, reading
663 fails and the download is restarted. This option does not directly af‐
664 fect the duration of the entire download.
665
666 Of course, the remote server may choose to terminate the connection
667 sooner than this option requires. The default read timeout is 900 sec‐
668 onds.
669
670 --limit-rate=amount
671 Limit the download speed to amount bytes per second. Amount may be ex‐
672 pressed in bytes, kilobytes with the k suffix, or megabytes with the m
673 suffix. For example, –limit-rate=20k will limit the retrieval rate to
674 20KB/s. This is useful when, for whatever reason, you don’t want Wget2
675 to consume the entire available bandwidth.
676
677 This option allows the use of decimal numbers, usually in conjunction
678 with power suffixes; for example, –limit-rate=2.5k is a legal value.
679
680 Note that Wget2 implements the limiting by sleeping the appropriate
681 amount of time after a network read that took less time than specified
682 by the rate. Eventually this strategy causes the TCP transfer to slow
683 down to approximately the specified rate. However, it may take some
684 time for this balance to be achieved, so don’t be surprised if limiting
685 the rate doesn’t work well with very small files.
686
687 -w seconds, --wait=seconds
688 Wait the specified number of seconds between the retrievals. Use of
689 this option is recommended, as it lightens the server load by making
690 the requests less frequent. Instead of in seconds, the time can be
691 specified in minutes using the “m” suffix, in hours using “h” suffix,
692 or in days using “d” suffix.
693
694 Specifying a large value for this option is useful if the network or
695 the destination host is down, so that Wget2 can wait long enough to
696 reasonably expect the network error to be fixed before the retry. The
697 waiting interval specified by this function is influenced by “–random-
698 wait”, which see.
699
700 --waitretry=seconds
701 If you don’t want Wget2 to wait between every retrieval, but only be‐
702 tween retries of failed downloads, you can use this option. Wget2 will
703 use linear backoff, waiting 1 second after the first failure on a given
704 file, then waiting 2 seconds after the second failure on that file, up
705 to the maximum number of seconds you specify.
706
707 By default, Wget2 will assume a value of 10 seconds.
708
709 --random-wait
710 Some web sites may perform log analysis to identify retrieval programs
711 such as Wget2 by looking for statistically significant similarities in
712 the time between requests. This option causes the time between re‐
713 quests to vary between 0.5 and 1.5 ### wait seconds, where wait was
714 specified using the –wait option, in order to mask Wget2’s presence
715 from such analysis.
716
717 A 2001 article in a publication devoted to development on a popular
718 consumer platform provided code to perform this analysis on the fly.
719 Its author suggested blocking at the class C address level to ensure
720 automated retrieval programs were blocked despite changing DHCP-sup‐
721 plied addresses.
722
723 The --random-wait option was inspired by this ill-advised recommenda‐
724 tion to block many unrelated users from a web site due to the actions
725 of one.
726
727 --no-proxy[=exceptions]
728 If no argument is given, we try to stay backward compatible with
729 Wget1.x and don’t use proxies, even if the appropriate *_proxy environ‐
730 ment variable is defined.
731
732 If a comma-separated list of exceptions (domains/IPs) is given, these
733 exceptions are accessed without using a proxy. It overrides the
734 `no_proxy' environment variable.
735
736 -Q quota, --quota=quota
737 Specify download quota for automatic retrievals. The value can be
738 specified in bytes (default), kilobytes (with k suffix), or megabytes
739 (with m suffix).
740
741 Note that quota will never affect downloading a single file. So if you
742 specify
743
744 wget2 -Q10k https://example.com/bigfile.gz
745
746 all of the bigfile.gz will be downloaded. The same goes even when sev‐
747 eral URLs are specified on the command-line. However, quota is re‐
748 spected when retrieving either recursively, or from an input file.
749 Thus you may safely type
750
751 wget2 -Q2m -i sites
752
753 download will be aborted when the quota is exceeded.
754
755 Setting quota to 0 or to inf unlimits the download quota.
756
757 --restrict-file-names=modes
758 Change which characters found in remote URLs must be escaped during
759 generation of local filenames. Characters that are restricted by this
760 option are escaped, i.e. replaced with %HH, where HH is the hexadecimal
761 number that corresponds to the restricted character. This option may
762 also be used to force all alphabetical cases to be either lower- or up‐
763 percase.
764
765 By default, Wget2 escapes the characters that are not valid or safe as
766 part of file names on your operating system, as well as control charac‐
767 ters that are typically unprintable. This option is useful for chang‐
768 ing these defaults, perhaps because you are downloading to a non-native
769 partition, or because you want to disable escaping of the control char‐
770 acters, or you want to further restrict characters to only those in the
771 ASCII range of values.
772
773 The modes are a comma-separated set of text values. The acceptable
774 values are unix, windows, nocontrol, ascii, lowercase, and uppercase.
775 The values unix and windows are mutually exclusive (one will override
776 the other), as are lowercase and uppercase. Those last are special
777 cases, as they do not change the set of characters that would be es‐
778 caped, but rather force local file paths to be converted either to low‐
779 er- or uppercase.
780
781 When “unix” is specified, Wget2 escapes the character / and the control
782 characters in the ranges 0–31 and 128–159. This is the default on
783 Unix-like operating systems.
784
785 When “windows” is given, Wget2 escapes the characters , |, /, :, ?, “,
786 *, <, >, and the control characters in the ranges 0–31 and 128–159. In
787 addition to this, Wget2 in Windows mode uses + instead of : to separate
788 host and port in local file names, and uses @ instead of ? to separate
789 the query portion of the file name from the rest. Therefore, a URL
790 that would be saved as www.xemacs.org:4300/search.pl?input=blah in Unix
791 mode would be saved as www.xemacs.org+4300/search.pl@input=blah in Win‐
792 dows mode. This mode is the default on Windows.
793
794 If you specify nocontrol, then the escaping of the control characters
795 is also switched off. This option may make sense when you are down‐
796 loading URLs whose names contain UTF-8 characters, on a system which
797 can save and display filenames in UTF-8 (some possible byte values used
798 in UTF-8 byte sequences fall in the range of values designated by Wget2
799 as “controls”).
800
801 The ascii mode is used to specify that any bytes whose values are out‐
802 side the range of ASCII characters (that is, greater than 127) shall be
803 escaped. This can be useful when saving filenames whose encoding does
804 not match the one used locally.
805
806 -4, --inet4-only, -6, --inet6-only
807 Force connecting to IPv4 or IPv6 addresses. With –inet4-only or -4,
808 Wget2 will only connect to IPv4 hosts, ignoring AAAA records in DNS,
809 and refusing to connect to IPv6 addresses specified in URLs. Converse‐
810 ly, with –inet6-only or -6, Wget2 will only connect to IPv6 hosts and
811 ignore A records and IPv4 addresses.
812
813 Neither options should be needed normally. By default, an IPv6-aware
814 Wget2 will use the address family specified by the host’s DNS record.
815 If the DNS responds with both IPv4 and IPv6 addresses, Wget2 will try
816 them in sequence until it finds one it can connect to. (Also see
817 “–prefer-family” option described below.)
818
819 These options can be used to deliberately force the use of IPv4 or IPv6
820 address families on dual family systems, usually to aid debugging or to
821 deal with broken network configuration. Only one of –inet6-only and
822 –inet4-only may be specified at the same time. Neither option is
823 available in Wget2 compiled without IPv6 support.
824
825 --prefer-family=none/IPv4/IPv6
826 When given a choice of several addresses, connect to the addresses with
827 specified address family first. The address order returned by DNS is
828 used without change by default.
829
830 This avoids spurious errors and connect attempts when accessing hosts
831 that resolve to both IPv6 and IPv4 addresses from IPv4 networks. For
832 example, www.kame.net resolves to 2001:200:0:8002:203:47ff:fea5:3085
833 and to 203.178.141.194. When the preferred family is “IPv4”, the IPv4
834 address is used first; when the preferred family is “IPv6”, the IPv6
835 address is used first; if the specified value is “none”, the address
836 order returned by DNS is used without change.
837
838 Unlike -4 and -6, this option doesn’t inhibit access to any address
839 family, it only changes the order in which the addresses are accessed.
840 Also note that the reordering performed by this option is stable. It
841 doesn’t affect order of addresses of the same family. That is, the
842 relative order of all IPv4 addresses and of all IPv6 addresses remains
843 intact in all cases.
844
845 --tcp-fastopen
846 Enable support for TCP Fast Open (TFO) (default: on).
847
848 TFO reduces connection latency by 1 RT on “hot” connections (2nd+ con‐
849 nection to the same host in a certain amount of time).
850
851 Currently this works on recent Linux and OSX kernels, on HTTP and
852 HTTPS.
853
854 --dns-cache-preload=file
855 Load a list of IP / Name tuples into the DNS cache.
856
857 The format of file is like /etc/hosts: IP-address whitespace Name
858
859 This allows to save domain name lookup time, which is a bottleneck in
860 some use cases. Also, the use of HOSTALIASES (which is not portable)
861 can be mimiced by this option.
862
863 --dns-cache
864 Enable DNS caching (default: on).
865
866 Normally, Wget2 remembers the IP addresses it looked up from DNS so it
867 doesn’t have to repeatedly contact the DNS server for the same (typi‐
868 cally small) set of hosts it retrieves from. This cache exists in mem‐
869 ory only; a new Wget2 run will contact DNS again.
870
871 However, it has been reported that in some situations it is not desir‐
872 able to cache host names, even for the duration of a short-running ap‐
873 plication like Wget2. With --no-dns-cache Wget2 issues a new DNS
874 lookup (more precisely, a new call to “gethostbyname” or “getaddrinfo”)
875 each time it makes a new connection. Please note that this option will
876 not affect caching that might be performed by the resolving library or
877 by an external caching layer, such as NSCD.
878
879 --retry-connrefused
880 Consider “connection refused” a transient error and try again. Normal‐
881 ly Wget2 gives up on a URL when it is unable to connect to the site be‐
882 cause failure to connect is taken as a sign that the server is not run‐
883 ning at all and that retries would not help. This option is for mir‐
884 roring unreliable sites whose servers tend to disappear for short peri‐
885 ods of time.
886
887 --user=user, --password=password
888 Specify the username user and password password for HTTP file re‐
889 trieval. This overrides the lookup of credentials in the .netrc file
890 (–netrc is enabled by default). These parameters can be overridden us‐
891 ing the –http-user and –http-password options for HTTP(S) connections.
892
893 If neither –http-proxy-user nor –http-proxy-password is given these
894 settings are also taken for proxy authentication.
895
896 --ask-password
897 Prompt for a password on the command line. Overrides the password set
898 by –password (if any).
899
900 --use-askpass=command
901 Prompt for a user and password using the specified command. Overrides
902 the user and/or password set by –user/–password (if any).
903
904 --no-iri
905 Turn off internationalized URI (IRI) support. Use –iri to turn it on.
906 IRI support is activated by default.
907
908 You can set the default state of IRI support using the “iri” command in
909 .wgetrc. That setting may be overridden from the command line.
910
911 --local-encoding=encoding
912 Force Wget2 to use encoding as the default system encoding. That af‐
913 fects how Wget2 converts URLs specified as arguments from locale to
914 UTF-8 for IRI support.
915
916 Wget2 use the function “nl_langinfo()” and then the “CHARSET” environ‐
917 ment variable to get the locale. If it fails, ASCII is used.
918
919 --remote-encoding=encoding
920 Force Wget2 to use encoding as the default remote server encoding.
921 That affects how Wget2 converts URIs found in files from remote encod‐
922 ing to UTF-8 during a recursive fetch. This options is only useful for
923 IRI support, for the interpretation of non-ASCII characters.
924
925 For HTTP, remote encoding can be found in HTTP “Content-Type” header
926 and in HTML “Content-Type http-equiv” meta tag.
927
928 --input-encoding=encoding
929 Use the specified encoding for the URLs read from --input-file. The
930 default is the local encoding.
931
932 --unlink
933 Force Wget2 to unlink file instead of clobbering existing file. This
934 option is useful for downloading to the directory with hardlinks.
935
936 --cut-url-get-vars
937 Remove HTTP GET Variables from URLs. For example “main.css?v=123” will
938 be changed to “main.css”. Be aware that this may have unintended side
939 effects, for example “image.php?name=sun” will be changed to “im‐
940 age.php”. The cutting happens before adding the URL to the download
941 queue.
942
943 --cut-file-get-vars
944 Remove HTTP GET Variables from filenames. For example “main.css?v=123”
945 will be changed to “main.css”.
946
947 Be aware that this may have unintended side effects, for example “im‐
948 age.php?name=sun” will be changed to “image.php”. The cutting happens
949 when saving the file, after downloading.
950
951 File names obtained from a “Content-Disposition” header are not affect‐
952 ed by this setting (see –content-disposition), and can be a solution
953 for this problem.
954
955 When “–trust-server-names” is used, the redirection URL is affected by
956 this setting.
957
958 --chunk-size=size
959 Download large files in multithreaded chunks. This switch specifies
960 the size of the chunks, given in bytes if no other byte multiple unit
961 is specified. By default it’s set on 0/off.
962
963 --max-threads=number
964 Specifies the maximum number of concurrent download threads for a re‐
965 source. The default is 5 but if you want to allow more or fewer this
966 is the option to use.
967
968 -s, --verify-sig[=fail|no-fail]
969 Enable PGP signature verification (when not prefixed with no-). When
970 enabled Wget2 will attempt to download and verify PGP signatures
971 against their corresponding files. Any file downloaded that has a con‐
972 tent type beginning with application/ will cause Wget2 to request the
973 signature for that file.
974
975 The name of the signature file is computed by appending the extension
976 to the full path of the file that was just downloaded. The extension
977 used is defined by the --signature-extensions option. If the content
978 type for the signature request is application/pgp-signature, Wget2 will
979 attempt to verify the signature against the original file. By default,
980 if a signature file cannot be found (I.E. the request for it gets a
981 404 status code) Wget2 will exit with an error code.
982
983 This behavior can be tuned using the following arguments: * fail: This
984 is the default, meaning that this is the value when you supply the flag
985 without an argument. Indicates that missing signature files will cause
986 Wget2 to exit with an error code. * no-fail: This value allows missing
987 signature files. A 404 message will still be issued, but the program
988 will exit normally (assuming no unrelated errors).
989
990 Additionally, --no-verify-sig disables signature checking altogether
991 --no-verify-sig does not allow any arguments.
992
993 --signature-extensions
994 Specify the file extensions for signature files, without the leading
995 “.”. You may specify multiple extensions as a comma separated list.
996 All the provided extensions will be tried simultaneously when looking
997 for the signature file. The default is “sig”.
998
999 --gnupg-homedir
1000 Specifies the gnupg home directory to use when verifying PGP signatures
1001 on downloaded files. The default for this is your system’s default
1002 home directory.
1003
1004 --verify-save-failed
1005 Instructs Wget2 to keep files that don’t pass PGP signature validation.
1006 The default is to delete files that fail validation.
1007
1008 --xattr
1009 Saves documents metadata as “user POSIX Extended Attributes” (default:
1010 on). This feature only works if the file system supports it. More in‐
1011 fo on https://freedesktop.org/wiki/CommonExtendedAttributes.
1012
1013 Wget2 currently sets * user.xdg.origin.url * user.xdg.referrer.url *
1014 user.mime_type * user.charset
1015
1016 To display the extended attributes of a file (Linux): getfattr -d
1017 <file>
1018
1019 --metalink
1020 Follow/process metalink URLs without saving them (default: on).
1021
1022 Metalink files describe downloads incl. mirrors, files, checksums, sig‐
1023 natures. This allows chunked downloads, automatically taking the near‐
1024 est mirrors, preferring the fastest mirrors and checking the download
1025 for integrity.
1026
1027 --fsync-policy
1028 Enables disk syncing after each write (default: off).
1029
1030 --http2-request-window=number
1031 Set max. number of parallel streams per HTTP/2 connection (default:
1032 30).
1033
1034 --keep-extension
1035 This option changes the behavior for creating a unique filename if a
1036 file already exists.
1037
1038 The standard (default) pattern for file names is <filename>.<N>, the
1039 new pattern is <basename>_<N>.<ext>.
1040
1041 The idea is to use such files without renaming when the use depends on
1042 the extension, like on Windows.
1043
1044 This option doesn not change the behavior of --backups.
1045
1046 Directory Options
1047 -nd, --no-directories
1048 Do not create a hierarchy of directories when retrieving recursively.
1049 With this option turned on, all files will get saved to the current di‐
1050 rectory, without clobbering (if a name shows up more than once, the
1051 filenames will get extensions .n).
1052
1053 -x, --force-directories
1054 The opposite of -nd: create a hierarchy of directories, even if one
1055 would not have been created otherwise. E.g. wget2 -x https://exam‐
1056 ple.com/robots.txt will save the downloaded file to example.com/ro‐
1057 bots.txt.
1058
1059 -nH, --no-host-directories
1060 Disable generation of host-prefixed directories. By default, invoking
1061 Wget2 with -r https://example.com/ will create a structure of directo‐
1062 ries beginning with example.com/. This option disables such behavior.
1063
1064 --protocol-directories
1065 Use the protocol name as a directory component of local file names.
1066 For example, with this option, wget2 -r https://example.com will save
1067 to https/example.com/... rather than just to example.com/....
1068
1069 --cut-dirs=number
1070 Ignore a number of directory components. This is useful for getting a
1071 fine-grained control over the directory where recursive retrieval will
1072 be saved.
1073
1074 Take, for example, the directory at https://example.com/pub/sub/. If
1075 you retrieve it with -r, it will be saved locally under exam‐
1076 ple.com/pub/sub/. While the -nH option can remove the example.com/
1077 part, you are still stuck with pub/sub/. This is where --cut-dirs
1078 comes in handy; it makes Wget2 not “see” a number of remote directory
1079 components. Here are several examples of how --cut-dirs option works.
1080 No options -> example.com/pub/sub/ --cut-dirs=1 -> ex‐
1081 ample.com/sub/ --cut-dirs=2 -> example.com/ -nH
1082 -> pub/sub/ -nH --cut-dirs=1 -> sub/ -nH --cut-dirs=2 -> .
1083 If you just want to get rid of the directory structure, this option is
1084 similar to a combination of -nd and -P. However, unlike -nd, --cut-
1085 dirs does not lose with subdirectories. For instance, with -nH --cut-
1086 dirs=1, a beta/ subdirectory will be placed to sub/beta/, as one would
1087 expect.
1088
1089 -P prefix, --directory-prefix=prefix
1090 Set directory prefix to prefix. The directory prefix is the directory
1091 where all other files and subdirectories will be saved to, i.e. the top
1092 of the retrieval tree. The default is ., the current directory. If
1093 the directory prefix doesn’t exist, it will be created.
1094
1095 HTTP Options
1096 --default-page=name
1097 Use name as the default file name when it isn’t known (i.e., for URLs
1098 that end in a slash), instead of index.html.
1099
1100 --default-http-port=port
1101 Set the default port for HTTP URLs (default: 80).
1102
1103 This is mainly for testing purposes.
1104
1105 --default-https-port=port
1106 Set the default port for HTTPS URLs (default: 443).
1107
1108 This is mainly for testing purposes.
1109
1110 -E, --adjust-extension
1111 If a file of type application/xhtml+xml or text/html is downloaded and
1112 the URL does not end with the regexp \.[Hh][Tt][Mm][Ll]?, this option
1113 will cause the suffix .html to be appended to the local filename. This
1114 is useful, for instance, when you’re mirroring a remote site that uses
1115 .asp pages, but you want the mirrored pages to be viewable on your
1116 stock Apache server. Another good use for this is when you’re down‐
1117 loading CGI-generated materials. A URL like https://example.com/arti‐
1118 cle.cgi?25 will be saved as article.cgi?25.html.
1119
1120 Note that filenames changed in this way will be re-downloaded every
1121 time you re-mirror a site, because Wget2 can’t tell that the local
1122 X.html file corresponds to remote URL X (since it doesn’t yet know that
1123 the URL produces output of type text/html or application/xhtml+xml.
1124
1125 Wget2 will also ensure that any downloaded files of type text/css end
1126 in the suffix .css.
1127
1128 At some point in the future, this option may well be expanded to in‐
1129 clude suffixes for other types of content, including content types that
1130 are not parsed by Wget.
1131
1132 --http-user=user, --http-password=password
1133 Specify the user and password for HTTP authentication. According to
1134 the type of the challenge, Wget will encode them using either the “ba‐
1135 sic” (insecure), the “digest”, or the Windows “NTLM” authentication
1136 scheme.
1137
1138 If possible, put your credentials into ~/.netrc (see also --netrc and
1139 --netrc-file options) or into ~/.wgetrc. This is far more secure than
1140 using the command line which can be seen by any other user. If the
1141 passwords are really important, do not leave them lying in those files
1142 either. Edit the files and delete them after Wget2 has started the
1143 download.
1144
1145 Also see --use-askpass and --ask-password for an interactive method to
1146 provide your password.
1147
1148 --http-proxy-user=user, --http-proxy-password=password
1149 Specify the user and password for HTTP proxy authentication. See
1150 --http-user for details.
1151
1152 --http-proxy=proxies
1153 Set comma-separated list of HTTP proxies. The environment variable
1154 `http_proxy' will be overridden.
1155
1156 Exceptions can be set via the environment variable `no_proxy' or via
1157 --no-proxy.
1158
1159 --https-proxy=proxies
1160 Set comma-separated list of HTTPS proxies. The environment variable
1161 `https_proxy' will be overridden.
1162
1163 Exceptions can be set via the environment variable `no_proxy' or via
1164 --no-proxy.
1165
1166 --no-http-keep-alive
1167 Turn off the “keep-alive” feature for HTTP(S) downloads. Normally,
1168 Wget2 asks the server to keep the connection open so that, when you
1169 download more than one document from the same server, they get trans‐
1170 ferred over the same TCP connection. This saves time and at the same
1171 time reduces the load on the server.
1172
1173 This option is useful when, for some reason, persistent (keep-alive)
1174 connections don’t work for you, for example due to a server bug or due
1175 to the inability of server-side scripts to cope with the connections.
1176
1177 --no-cache
1178 Disable server-side cache. In this case, Wget2 will send the remote
1179 server appropriate directives (Cache-Control: no- cache and Pragma: no-
1180 cache) to get the file from the remote service, rather than returning
1181 the cached version. This is especially useful for retrieving and
1182 flushing out-of-date documents on proxy servers.
1183
1184 Caching is allowed by default.
1185
1186 --no-cookies
1187 Disable the use of cookies. Cookies are a mechanism for maintaining
1188 server-side state. The server sends the client a cookie using the
1189 “Set-Cookie” header, and the client responds with the same cookie upon
1190 further requests. Since cookies allow the server owners to keep track
1191 of visitors and for sites to exchange this information, some consider
1192 them a breach of privacy. The default is to use cookies; however,
1193 storing cookies is not on by default.
1194
1195 --load-cookies file
1196 Load cookies from file before the first HTTP(S) retrieval. file is a
1197 textual file in the format originally used by Netscape’s cookies.txt
1198 file.
1199
1200 You will typically use this option when mirroring sites that require
1201 that you be logged in to access some or all of their content. The lo‐
1202 gin process typically works by the web server issuing an HTTP cookie
1203 upon receiving and verifying your credentials. The cookie is then re‐
1204 sent by the browser when accessing that part of the site, and so proves
1205 your identity.
1206
1207 Mirroring such a site requires Wget2 to send the same cookies your
1208 browser sends when communicating with the site. This is achieved by
1209 –load-cookies: simply point Wget2 to the location of the cookies.txt
1210 file, and it will send the same cookies your browser would send in the
1211 same situation. Different browsers keep textual cookie files in dif‐
1212 ferent locations:
1213
1214 “Netscape 4.x.” The cookies are in ~/.netscape/cookies.txt.
1215
1216 “Mozilla and Netscape 6.x.” Mozilla’s cookie file is also named cook‐
1217 ies.txt, located somewhere under ~/.mozilla, in the directory of your
1218 profile. The full path usually ends up looking somewhat like ~/.mozil‐
1219 la/default/some-weird- string/cookies.txt.
1220
1221 “Internet Explorer.” You can produce a cookie file Wget2 can use by us‐
1222 ing the File menu, Import and Export, Export Cookies. This has been
1223 tested with Internet Explorer 5; it is not guaranteed to work with ear‐
1224 lier versions.
1225
1226 “Other browsers.” If you are using a different browser to create your
1227 cookies, –load-cookies will only work if you can locate or produce a
1228 cookie file in the Netscape format that Wget2 expects.
1229
1230 If you cannot use --load-cookies, there might still be an alternative.
1231 If your browser supports a “cookie manager”, you can use it to view the
1232 cookies used when accessing the site you’re mirroring. Write down the
1233 name and value of the cookie, and manually instruct Wget2 to send those
1234 cookies, bypassing the “official” cookie support:
1235
1236 wget2 --no-cookies --header "Cookie: <name>=<value>"
1237
1238 --save-cookies file
1239 Save cookies to file before exiting. This will not save cookies that
1240 have expired or that have no expiry time (so-called “session cookies”),
1241 but also see –keep-session-cookies.
1242
1243 --keep-session-cookies
1244 When specified, causes –save-cookies to also save session cookies.
1245 Session cookies are normally not saved because they are meant to be
1246 kept in memory and forgotten when you exit the browser. Saving them is
1247 useful on sites that require you to log in or to visit the home page
1248 before you can access some pages. With this option, multiple Wget2
1249 runs are considered a single browser session as far as the site is con‐
1250 cerned.
1251
1252 Since the cookie file format does not normally carry session cookies,
1253 Wget2 marks them with an expiry timestamp of 0. Wget2’s –load-cookies
1254 recognizes those as session cookies, but it might confuse other
1255 browsers. Also note that cookies so loaded will be treated as other
1256 session cookies, which means that if you want –save-cookies to preserve
1257 them again, you must use –keep-session-cookies again.
1258
1259 --cookie-suffixes=file
1260 Load the public suffixes used for cookie checking from the given file.
1261
1262 Normally, the underlying libpsl loads this data from a system file or
1263 it has the data built in. In some cases you might want to load an up‐
1264 dated PSL, e.g. from https://publicsuffix.org/list/public_suf‐
1265 fix_list.dat.
1266
1267 The PSL allows to prevent setting of “super-cookies” that lead to cook‐
1268 ie privacy leakage. More details can be found on https://publicsuf‐
1269 fix.org/.
1270
1271 --ignore-length
1272 Unfortunately, some HTTP servers (CGI programs, to be more precise)
1273 send out bogus “Content-Length” headers, which makes Wget2 go wild, as
1274 it thinks not all the document was retrieved. You can spot this syn‐
1275 drome if Wget retries getting the same document again and again, each
1276 time claiming that the (otherwise normal) connection has closed on the
1277 very same byte.
1278
1279 With this option, Wget2 will ignore the “Content-Length” header as if
1280 it never existed.
1281
1282 --header=header-line
1283 Send header-line along with the rest of the headers in each HTTP re‐
1284 quest. The supplied header is sent as-is, which means it must contain
1285 name and value separated by colon, and must not contain newlines.
1286
1287 You may define more than one additional header by specifying –header
1288 more than once.
1289
1290 wget2 --header='Accept-Charset: iso-8859-2' \
1291 --header='Accept-Language: hr' \
1292 https://example.com/
1293
1294 Specification of an empty string as the header value will clear all
1295 previous user-defined headers.
1296
1297 This option can be used to override headers otherwise generated auto‐
1298 matically. This example instructs Wget2 to connect to localhost, but
1299 to specify example.com in the “Host” header:
1300
1301 wget2 --header="Host: example.com" http://localhost/
1302
1303 --max-redirect=number
1304 Specifies the maximum number of redirections to follow for a resource.
1305 The default is 20, which is usually far more than necessary. However,
1306 on those occasions where you want to allow more (or fewer), this is the
1307 option to use.
1308
1309 --proxy-user=user, --proxy-password=password [Not implemented, use --http-
1310 proxy-password]
1311 Specify the username user and password password for authentication on a
1312 proxy server. Wget2 will encode them using the “basic” authentication
1313 scheme.
1314
1315 Security considerations similar to those with --http-password pertain
1316 here as well.
1317
1318 --referer=url
1319 Include `Referer: url’ header in HTTP request. Useful for retrieving
1320 documents with server-side processing that assume they are always being
1321 retrieved by interactive web browsers and only come out properly when
1322 Referer is set to one of the pages that point to them.
1323
1324 --save-headers
1325 Save the headers sent by the HTTP server to the file, preceding the ac‐
1326 tual contents, with an empty line as the separator.
1327
1328 -U agent-string, --user-agent=agent-string
1329 Identify as agent-string to the HTTP server.
1330
1331 The HTTP protocol allows the clients to identify themselves using a
1332 “User-Agent” header field. This enables distinguishing the WWW soft‐
1333 ware, usually for statistical purposes or for tracing of protocol vio‐
1334 lations. Wget normally identifies as Wget/version, version being the
1335 current version number of Wget.
1336
1337 However, some sites have been known to impose the policy of tailoring
1338 the output according to the “User-Agent”-supplied information. While
1339 this is not such a bad idea in theory, it has been abused by servers
1340 denying information to clients other than (historically) Netscape or,
1341 more frequently, Microsoft Internet Explorer. This option allows you
1342 to change the “User-Agent” line issued by Wget. Use of this option is
1343 discouraged, unless you really know what you are doing.
1344
1345 Specifying empty user agent with –user-agent=“” instructs Wget2 not to
1346 send the “User-Agent” header in HTTP requests.
1347
1348 --post-data=string, --post-file=file
1349 Use POST as the method for all HTTP requests and send the specified da‐
1350 ta in the request body. –post-data sends string as data, whereas
1351 –post-file sends the contents of file. Other than that, they work in
1352 exactly the same way. In particular, they both expect content of the
1353 form “key1=value1&key2=value2”, with percent-encoding for special char‐
1354 acters; the only difference is that one expects its content as a com‐
1355 mand-line parameter and the other accepts its content from a file. In
1356 particular, –post-file is not for transmitting files as form attach‐
1357 ments: those must appear as “key=value” data (with appropriate percent-
1358 coding) just like everything else. Wget2 does not currently support
1359 “multipart/form-data” for transmitting POST data; only “application/x-
1360 www-form-urlencoded”. Only one of –post-data and –post-file should be
1361 specified.
1362
1363 Please note that wget2 does not require the content to be of the form
1364 “key1=value1&key2=value2”, and neither does it test for it. Wget2 will
1365 simply transmit whatever data is provided to it. Most servers however
1366 expect the POST data to be in the above format when processing HTML
1367 Forms.
1368
1369 When sending a POST request using the --post-file option, Wget2 treats
1370 the file as a binary file and will send every character in the POST re‐
1371 quest without stripping trailing newline or formfeed characters. Any
1372 other control characters in the text will also be sent as-is in the
1373 POST request.
1374
1375 Please be aware that Wget2 needs to know the size of the POST data in
1376 advance. Therefore the argument to “–post-file” must be a regular
1377 file; specifying a FIFO or something like /dev/stdin won’t work. It’s
1378 not quite clear how to work around this limitation inherent in
1379 HTTP/1.0. Although HTTP/1.1 introduces chunked transfer that doesn’t
1380 require knowing the request length in advance, a client can’t use chun‐
1381 ked unless it knows it’s talking to an HTTP/1.1 server. And it can’t
1382 know that until it receives a response, which in turn requires the re‐
1383 quest to have been completed – a chicken-and-egg problem.
1384
1385 If Wget2 is redirected after the POST request is completed, its behav‐
1386 iour depends on the response code returned by the server. In case of a
1387 301 Moved Permanently, 302 Moved Temporarily or 307 Temporary Redirect,
1388 Wget2 will, in accordance with RFC2616, continue to send a POST re‐
1389 quest. In case a server wants the client to change the Request method
1390 upon redirection, it should send a 303 See Other response code.
1391
1392 This example shows how to log in to a server using POST and then pro‐
1393 ceed to download the desired pages, presumably only accessible to au‐
1394 thorized users:
1395
1396 # Log in to the server. This can be done only once.
1397 wget2 --save-cookies cookies.txt \
1398 --post-data 'user=foo&password=bar' \
1399 http://example.com/auth.php
1400
1401 # Now grab the page or pages we care about.
1402 wget2 --load-cookies cookies.txt \
1403 -p http://example.com/interesting/article.php
1404
1405 If the server is using session cookies to track user authentication,
1406 the above will not work because --save-cookies will not save them (and
1407 neither will browsers) and the cookies.txt file will be empty. In that
1408 case use –keep-session-cookies along with –save-cookies to force saving
1409 of session cookies.
1410
1411 --method=HTTP-Method
1412 For the purpose of RESTful scripting, Wget2 allows sending of other
1413 HTTP Methods without the need to explicitly set them using –head‐
1414 er=Header-Line. Wget2 will use whatever string is passed to it after
1415 –method as the HTTP Method to the server.
1416
1417 --body-data=Data-String, --body-file=Data-File
1418 Must be set when additional data needs to be sent to the server along
1419 with the Method specified using --method. --body-data sends string as
1420 data, whereas –body-file sends the contents of file. Other than that,
1421 they work in exactly the same way.
1422
1423 Currently, --body-file is not for transmitting files as a whole. Wget2
1424 does not currently support “multipart/form-data” for transmitting data;
1425 only “application/x-www-form-urlencoded”. In the future, this may be
1426 changed so that wget2 sends the –body-file as a complete file instead
1427 of sending its contents to the server. Please be aware that Wget2
1428 needs to know the contents of BODY Data in advance, and hence the argu‐
1429 ment to –body-file should be a regular file. See –post-file for a more
1430 detailed explanation. Only one of –body-data and –body-file should be
1431 specified.
1432
1433 If Wget2 is redirected after the request is completed, Wget2 will sus‐
1434 pend the current method and send a GET request till the redirection is
1435 completed. This is true for all redirection response codes except 307
1436 Temporary Redirect which is used to explicitly specify that the request
1437 method should not change. Another exception is when the method is set
1438 to “POST”, in which case the redirection rules specified under --post-
1439 data are followed.
1440
1441 --content-disposition
1442 If this is set to on, experimental (not fully-functional) support for
1443 “Content-Disposition” headers is enabled. This can currently result in
1444 extra round-trips to the server for a “HEAD” request, and is known to
1445 suffer from a few bugs, which is why it is not currently enabled by de‐
1446 fault.
1447
1448 This option is useful for some file-downloading CGI programs that use
1449 “Content-Disposition” headers to describe what the name of a downloaded
1450 file should be.
1451
1452 --content-on-error
1453 If this is set to on, wget2 will not skip the content when the server
1454 responds with a http status code that indicates error.
1455
1456 --save-content-on
1457 This takes a comma-separated list of HTTP status codes to save the con‐
1458 tent for.
1459
1460 You can use ’*’ for ANY. An exclamation mark (!) in front of a code
1461 means `exception'.
1462
1463 Example 1: --save-content-on="*,!404" would save the content on any
1464 HTTP status, except for 404.
1465
1466 Example 2: --save-content-on=404 would save the content only on HTTP
1467 status 404.
1468
1469 The older --content-on-error behaves like --save-content-on=*.
1470
1471 --trust-server-names
1472 If this is set to on, on a redirect the last component of the redirect‐
1473 ion URL will be used as the local file name. By default it is used the
1474 last component in the original URL.
1475
1476 --auth-no-challenge
1477 If this option is given, Wget2 will send Basic HTTP authentication in‐
1478 formation (plaintext username and password) for all requests.
1479
1480 Use of this option is not recommended, and is intended only to support
1481 some few obscure servers, which never send HTTP authentication chal‐
1482 lenges, but accept unsolicited auth info, say, in addition to form-
1483 based authentication.
1484
1485 --compression=TYPE
1486 If this TYPE(identity, gzip, deflate, xz, lzma, br, bzip2, zstd, lzip
1487 or any combination of it) is given, Wget2 will set “Accept-Encoding”
1488 header accordingly. --no-compression means no “Accept-Encoding” header
1489 at all. To set “Accept-Encoding” to a custom value, use --no-compres‐
1490 sion in combination with --header="Accept-Encoding: xxx".
1491
1492 Compatibility-Note: none type in Wget 1.X has the same meaning as iden‐
1493 tity type in Wget2.
1494
1495 --download-attr=[strippath|usepath]
1496 The download HTML5 attribute may specify (or better: suggest) a file
1497 name for the href URL in a and area tags. This option tells Wget2 to
1498 make use of this file name when saving. The two possible values are
1499 `strippath' to strip the path from the file name. This is the default.
1500
1501 The value `usepath' takes the file name as as including the directory.
1502 This is very dangerous and we can’t stress enough not to use it on un‐
1503 trusted input or servers ! Only use this if you really trust the input
1504 or the server.
1505
1506 HTTPS (SSL/TLS) Options
1507 To support encrypted HTTP (HTTPS) downloads, Wget2 must be compiled
1508 with an external SSL library. The current default is GnuTLS. In addi‐
1509 tion, Wget2 also supports HSTS (HTTP Strict Transport Security). If
1510 Wget2 is compiled without SSL support, none of these options are avail‐
1511 able.
1512
1513 --secure-protocol=protocol
1514 Choose the secure protocol to be used (default: auto).
1515
1516 Legal values are auto, SSLv3, TLSv1, TLSv1_1, TLSv1_2, TLSv1_3 and PFS.
1517
1518 If auto is used, the TLS library’s default is used.
1519
1520 Specifying SSLv3 forces the use of the SSL3. This is useful when talk‐
1521 ing to old and buggy SSL server implementations that make it hard for
1522 the underlying TLS library to choose the correct protocol version.
1523
1524 Specifying PFS enforces the use of the so-called Perfect Forward Secu‐
1525 rity cipher suites. In short, PFS adds security by creating a one-time
1526 key for each TLS connection. It has a bit more CPU impact on client
1527 and server. We use known to be secure ciphers (e.g. no MD4) and the
1528 TLS protocol.
1529
1530 TLSv1 enables TLS1.0 or higher. TLSv1_1 enables TLS1.1 or higher.
1531 TLSv1_2 enables TLS1.2 or higher. TLSv1_3 enables TLS1.3 or higher.
1532
1533 Any other protocol string is directly given to the TLS library, cur‐
1534 rently GnuTLS, as a “priority” or “cipher” string. This is for users
1535 who know what they are doing.
1536
1537 --https-only
1538 When in recursive mode, only HTTPS links are followed.
1539
1540 --no-check-certificate
1541 Don’t check the server certificate against the available certificate
1542 authorities. Also don’t require the URL host name to match the common
1543 name presented by the certificate.
1544
1545 The default is to verify the server’s certificate against the recog‐
1546 nized certificate authorities, breaking the SSL handshake and aborting
1547 the download if the verification fails. Although this provides more
1548 secure downloads, it does break interoperability with some sites that
1549 worked with previous Wget versions, particularly those using self-
1550 signed, expired, or otherwise invalid certificates. This option forces
1551 an “insecure” mode of operation that turns the certificate verification
1552 errors into warnings and allows you to proceed.
1553
1554 If you encounter “certificate verification” errors or ones saying that
1555 “common name doesn’t match requested host name”, you can use this op‐
1556 tion to bypass the verification and proceed with the download. Only
1557 use this option if you are otherwise convinced of the site’s authentic‐
1558 ity, or if you really don’t care about the validity of its certificate.
1559 It is almost always a bad idea not to check the certificates when
1560 transmitting confidential or important data. For self-signed/internal
1561 certificates, you should download the certificate and verify against
1562 that instead of forcing this insecure mode. If you are really sure of
1563 not desiring any certificate verification, you can specify –check-cer‐
1564 tificate=quiet to tell Wget2 to not print any warning about invalid
1565 certificates, albeit in most cases this is the wrong thing to do.
1566
1567 --certificate=file
1568 Use the client certificate stored in file. This is needed for servers
1569 that are configured to require certificates from the clients that con‐
1570 nect to them. Normally a certificate is not required and this switch
1571 is optional.
1572
1573 --certificate-type=type
1574 Specify the type of the client certificate. Legal values are PEM (as‐
1575 sumed by default) and DER, also known as ASN1.
1576
1577 --private-key=file
1578 Read the private key from file. This allows you to provide the private
1579 key in a file separate from the certificate.
1580
1581 --private-key-type=type
1582 Specify the type of the private key. Accepted values are PEM (the de‐
1583 fault) and DER.
1584
1585 --ca-certificate=file
1586 Use file as the file with the bundle of certificate authorities (“CA”)
1587 to verify the peers. The certificates must be in PEM format.
1588
1589 Without this option Wget2 looks for CA certificates at the system-spec‐
1590 ified locations, chosen at OpenSSL installation time.
1591
1592 --ca-directory=directory
1593 Specifies directory containing CA certificates in PEM format. Each
1594 file contains one CA certificate, and the file name is based on a hash
1595 value derived from the certificate. This is achieved by processing a
1596 certificate directory with the “c_rehash” utility supplied with
1597 OpenSSL. Using --ca-directory is more efficient than --ca-certificate
1598 when many certificates are installed because it allows Wget2 to fetch
1599 certificates on demand.
1600
1601 Without this option Wget2 looks for CA certificates at the system-spec‐
1602 ified locations, chosen at OpenSSL installation time.
1603
1604 --crl-file=file
1605 Specifies a CRL file in file. This is needed for certificates that
1606 have been revocated by the CAs.
1607
1608 --random-file=file
1609 [OpenSSL and LibreSSL only] Use file as the source of random data for
1610 seeding the pseudo-random number generator on systems without
1611 /dev/urandom.
1612
1613 On such systems the SSL library needs an external source of randomness
1614 to initialize. Randomness may be provided by EGD (see –egd-file below)
1615 or read from an external source specified by the user. If this option
1616 is not specified, Wget2 looks for random data in $RANDFILE or, if that
1617 is unset, in $HOME/.rnd.
1618
1619 If you’re getting the “Could not seed OpenSSL PRNG; disabling SSL.” er‐
1620 ror, you should provide random data using some of the methods described
1621 above.
1622
1623 --egd-file=file
1624 [OpenSSL only] Use file as the EGD socket. EGD stands for Entropy
1625 Gathering Daemon, a user-space program that collects data from various
1626 unpredictable system sources and makes it available to other programs
1627 that might need it. Encryption software, such as the SSL library,
1628 needs sources of non-repeating randomness to seed the random number
1629 generator used to produce cryptographically strong keys.
1630
1631 OpenSSL allows the user to specify his own source of entropy using the
1632 “RAND_FILE” environment variable. If this variable is unset, or if the
1633 specified file does not produce enough randomness, OpenSSL will read
1634 random data from EGD socket specified using this option.
1635
1636 If this option is not specified (and the equivalent startup command is
1637 not used), EGD is never contacted. EGD is not needed on modern Unix
1638 systems that support /dev/urandom.
1639
1640 --hsts
1641 Wget2 supports HSTS (HTTP Strict Transport Security, RFC 6797) by de‐
1642 fault. Use --no-hsts to make Wget2 act as a non-HSTS-compliant UA. As
1643 a consequence, Wget2 would ignore all the “Strict-Transport-Security”
1644 headers, and would not enforce any existing HSTS policy.
1645
1646 --hsts-file=file
1647 By default, Wget2 stores its HSTS database in ~/.wget-hsts. You can
1648 use –hsts-file to override this. Wget2 will use the supplied file as
1649 the HSTS database. Such file must conform to the correct HSTS database
1650 format used by Wget. If Wget2 cannot parse the provided file, the be‐
1651 haviour is unspecified.
1652
1653 The Wget2’s HSTS database is a plain text file. Each line contains an
1654 HSTS entry (ie. a site that has issued a “Strict-Transport-Security”
1655 header and that therefore has specified a concrete HSTS policy to be
1656 applied). Lines starting with a dash (“#”) are ignored by Wget.
1657 Please note that in spite of this convenient human-readability hand-
1658 hacking the HSTS database is generally not a good idea.
1659
1660 An HSTS entry line consists of several fields separated by one or more
1661 whitespace:
1662
1663 <hostname> SP [<port>] SP <include subdomains> SP <created> SP <max-age>
1664
1665 The hostname and port fields indicate the hostname and port to which
1666 the given HSTS policy applies. The port field may be zero, and it
1667 will, in most of the cases. That means that the port number will not
1668 be taken into account when deciding whether such HSTS policy should be
1669 applied on a given request (only the hostname will be evaluated). When
1670 port is different to zero, both the target hostname and the port will
1671 be evaluated and the HSTS policy will only be applied if both of them
1672 match. This feature has been included for testing/development purposes
1673 only. The Wget2 testsuite (in testenv/) creates HSTS databases with
1674 explicit ports with the purpose of ensuring Wget2’s correct behaviour.
1675 Applying HSTS policies to ports other than the default ones is discour‐
1676 aged by RFC 6797 (see Appendix B “Differences between HSTS Policy and
1677 Same-Origin Policy”). Thus, this functionality should not be used in
1678 production environments and port will typically be zero. The last
1679 three fields do what they are expected to. The field include_subdo‐
1680 mains can either be 1 or 0 and it signals whether the subdomains of the
1681 target domain should be part of the given HSTS policy as well. The
1682 created and max-age fields hold the timestamp values of when such entry
1683 was created (first seen by Wget) and the HSTS-defined value `max-age',
1684 which states how long should that HSTS policy remain active, measured
1685 in seconds elapsed since the timestamp stored in created. Once that
1686 time has passed, that HSTS policy will no longer be valid and will
1687 eventually be removed from the database.
1688
1689 If you supply your own HSTS database via –hsts-file, be aware that
1690 Wget2 may modify the provided file if any change occurs between the
1691 HSTS policies requested by the remote servers and those in the file.
1692 When Wget2 exits, it effectively updates the HSTS database by rewriting
1693 the database file with the new entries.
1694
1695 If the supplied file does not exist, Wget2 will create one. This file
1696 will contain the new HSTS entries. If no HSTS entries were generated
1697 (no “Strict-Transport-Security” headers were sent by any of the
1698 servers) then no file will be created, not even an empty one. This be‐
1699 haviour applies to the default database file (~/.wget-hsts) as well: it
1700 will not be created until some server enforces an HSTS policy.
1701
1702 Care is taken not to override possible changes made by other Wget2 pro‐
1703 cesses at the same time over the HSTS database. Before dumping the up‐
1704 dated HSTS entries on the file, Wget2 will re-read it and merge the
1705 changes.
1706
1707 Using a custom HSTS database and/or modifying an existing one is dis‐
1708 couraged. For more information about the potential security threats
1709 arose from such practice, see section 14 “Security Considerations” of
1710 RFC 6797, specially section 14.9 “Creative Manipulation of HSTS Policy
1711 Store”.
1712
1713 --hsts-preload
1714 Enable loading of a HSTS Preload List as supported by libhsts. (de‐
1715 fault: on, if built with libhsts).
1716
1717 --hsts-preload-file=file
1718 If built with libhsts, Wget2 uses the HSTS data provided by the distri‐
1719 bution. If there is no such support by the distribution or if you want
1720 to load your own file, use this option.
1721
1722 The data file must be in DAFSA format as generated by libhsts’ tool
1723 hsts-make-dafsa.
1724
1725 --hpkp
1726 Enable HTTP Public Key Pinning (HPKP) (default: on).
1727
1728 This is a Trust On First Use (TOFU) mechanism to add another security
1729 layer to HTTPS (RFC 7469). It persistently stores the data into
1730 ~/.wget-hpkp which can be changed via the --hpkp-fileoption.
1731
1732 --hpkp-file=file
1733 For HPKP (--hpkp) you need the certificate key data of a previously es‐
1734 tablished TLS session. Wget2 persistently stores this data in the giv‐
1735 en file (default: ~/.wget-hpkp).
1736
1737 To disable persistent storage use --no-hpkp-file.
1738
1739 --tls-resume
1740 Enable TLS Session Resumption which is disabled as default.
1741
1742 There are several security flaws related to TLS 1.2 session resumption
1743 which are explained in detail at: https://web.ar‐
1744 chive.org/web/20171103231804/https://blog.filippo.io/we-need-to-talk-
1745 about-session-tickets/
1746
1747 --tls-session-file=file
1748 For TLS Session Resumption (--tls-resume) you need the session data of
1749 a previously established TLS session. Wget2 persistently stores this
1750 data in the given file (default: ~/.wget-session).
1751
1752 To disable persistent storage use --no-tls-session-file.
1753
1754 --tls-false-start
1755 Enable TLS False start (default: on).
1756
1757 This reduces TLS negotiation by one RT and thus speeds up HTTPS connec‐
1758 tions.
1759
1760 More details at https://tools.ietf.org/html/rfc7918.
1761
1762 --check-hostname
1763 Enable TLS SNI verification (default: on).
1764
1765 --ocsp
1766 Enable OCSP server access to check the possible revocation the HTTPS
1767 server certificate(s) (default: on).
1768
1769 This procedure is pretty slow (connect to server, HTTP request, re‐
1770 sponse) and thus we support OSCP stapling (server sends OCSP response
1771 within TLS handshake) and persistent OCSP caching.
1772
1773 --ocsp-date
1774 Check if OCSP response is too old. (default: on)
1775
1776 --ocsp-nonce
1777 Allow nonce checking when verifying OCSP response. (default: on)
1778
1779 --ocsp-server
1780 Set OCSP server address (default: OCSP server given in certificate).
1781
1782 --ocsp-stapling
1783 Enable support for OCSP stapling (default: on).
1784
1785 --ocsp-file=file
1786 Set the file for persistent OCSP response caching (default: ~/.wget-oc‐
1787 sp).
1788
1789 To disable persistent OCSP caching use --no-ocsp-file.
1790
1791 --http2
1792 Enable HTTP/2 protocol (default: on).
1793
1794 Wget2 requests HTTP/2 via ALPN. If available it is preferred over
1795 HTTP/1.1. Up to 30 streams are used in parallel within a single con‐
1796 nection.
1797
1798 --http2-only
1799 Resist on using HTTP/2 and error if a server doesn’t accept it. This
1800 is mainly for testing.
1801
1802 --https-enforce=mode
1803 Sets how to deal with URLs that are not explicitly HTTPS (where scheme
1804 isn’t https://) (default: none)
1805
1806 mode=none
1807 Use HTTP for URLs without scheme. In recursive operation the scheme of
1808 the parent document is taken as default.
1809
1810 mode=soft
1811 Try HTTPS first when the scheme is HTTP or not given. On failure fall
1812 back to HTTP.
1813
1814 mode=hard
1815 Only use HTTPS, no matter if a HTTP scheme is given or not. Do not
1816 fall back to HTTP.
1817
1818 Recursive Retrieval Options
1819 -r, --recursive
1820 Turn on recursive retrieving. The default maximum depth is 5.
1821
1822 -l depth, --level=depth
1823 Specify recursion maximum depth level depth.
1824
1825 --delete-after
1826 This option tells Wget2 to delete every single file it downloads, after
1827 having done so. It is useful for pre- fetching popular pages through a
1828 proxy, e.g.:
1829
1830 wget2 -r -nd --delete-after https://example.com/~popular/page/
1831
1832 The -r option is to retrieve recursively, and -nd to not create direc‐
1833 tories.
1834
1835 Note that when –delete-after is specified, –convert-links is ignored,
1836 so .orig files are simply not created in the first place.
1837
1838 -k, --convert-links
1839 After the download is complete, convert the links in the document to
1840 make them suitable for local viewing. This affects not only the visi‐
1841 ble hyperlinks, but any part of the document that links to external
1842 content, such as embedded images, links to style sheets, hyperlinks to
1843 non-HTML content, etc.
1844
1845 Each link will be changed in one of the two ways:
1846
1847 1. The links to files that have been downloaded by Wget2 will be
1848 changed to refer to the file they point to as a relative link.
1849
1850 Example: if the downloaded file /foo/doc.html links to
1851 /bar/img.gif, also downloaded, then the link in doc.html will be
1852 modified to point to ../bar/img.gif. This kind of transformation
1853 works reliably for arbitrary combinations of directories.
1854
1855 2. The links to files that have not been downloaded by Wget2 will be
1856 changed to include host name and absolute path of the location they
1857 point to.
1858
1859 Example: if the downloaded file /foo/doc.html links to /bar/img.gif
1860 (or to ../bar/img.gif), then the link in doc.html will be modified
1861 to point to https://example.com/bar/img.gif.
1862
1863 Because of this, local browsing works reliably: if a linked file was
1864 downloaded, the link will refer to its local name; if it was not down‐
1865 loaded, the link will refer to its full Internet address rather than
1866 presenting a broken link. The fact that the former links are converted
1867 to relative links ensures that you can move the downloaded hierarchy to
1868 another directory.
1869
1870 Note that only at the end of the download can Wget2 know which links
1871 have been downloaded. Because of that, the work done by -k will be
1872 performed at the end of all the downloads.
1873
1874 --convert-file-only
1875 This option converts only the filename part of the URLs, leaving the
1876 rest of the URLs untouched. This filename part is sometimes referred
1877 to as the “basename”, although we avoid that term here in order not to
1878 cause confusion.
1879
1880 It works particularly well in conjunction with --adjust-extension, al‐
1881 though this coupling is not enforced. It proves useful to populate In‐
1882 ternet caches with files downloaded from different hosts.
1883
1884 Example: if some link points to //foo.com/bar.cgi?xyz with –adjust-ex‐
1885 tension asserted and its local destination is intended to be
1886 ./foo.com/bar.cgi?xyz.css, then the link would be converted to
1887 //foo.com/bar.cgi?xyz.css. Note that only the filename part has been
1888 modified. The rest of the URL has been left untouched, including the
1889 net path (“//”) which would otherwise be processed by Wget2 and con‐
1890 verted to the effective scheme (ie. “https://”).
1891
1892 -K, --backup-converted
1893 When converting a file, back up the original version with a .orig suf‐
1894 fix. Affects the behavior of -N.
1895
1896 -m, --mirror
1897 Turn on options suitable for mirroring. This option turns on recursion
1898 and time-stamping, sets infinite recursion depth. It is currently
1899 equivalent to -r -N -l inf.
1900
1901 -p, --page-requisites
1902 This option causes Wget2 to download all the files that are necessary
1903 to properly display a given HTML page. This includes such things as
1904 inlined images, sounds, and referenced stylesheets.
1905
1906 Ordinarily, when downloading a single HTML page, any requisite docu‐
1907 ments that may be needed to display it properly are not downloaded.
1908 Using -r together with -l can help, but since Wget2 does not ordinarily
1909 distinguish between external and inlined documents, one is generally
1910 left with “leaf documents” that are missing their requisites.
1911
1912 For instance, say document 1.html contains an <IMG> tag referencing
1913 1.gif and an <A> tag pointing to external document 2.html. Say that
1914 2.html is similar but that its image is 2.gif and it links to 3.html.
1915 Say this continues up to some arbitrarily high number.
1916
1917 If one executes the command:
1918
1919 wget2 -r -l 2 https://<site>/1.html
1920
1921 then 1.html, 1.gif, 2.html, 2.gif, and 3.html will be downloaded. As
1922 you can see, 3.html is without its requisite 3.gif because Wget2 is
1923 simply counting the number of hops (up to 2) away from 1.html in order
1924 to determine where to stop the recursion. However, with this command:
1925
1926 wget2 -r -l 2 -p https://<site>/1.html
1927
1928 all the above files and 3.html’s requisite 3.gif will be downloaded.
1929 Similarly,
1930
1931 wget2 -r -l 1 -p https://<site>/1.html
1932
1933 will cause 1.html, 1.gif, 2.html, and 2.gif to be downloaded. One
1934 might think that:
1935
1936 wget2 -r -l 0 -p https://<site>/1.html
1937
1938 would download just 1.html and 1.gif, but unfortunately this is not the
1939 case, because -l 0 is equivalent to -l inf, that is, infinite recur‐
1940 sion. To download a single HTML page (or a handful of them, all speci‐
1941 fied on the command-line or in a -i URL input file) and its (or their)
1942 requisites, simply leave off -r and -l:
1943
1944 wget2 -p https://<site>/1.html
1945
1946 Note that Wget2 will behave as if -r had been specified, but only that
1947 single page and its requisites will be downloaded. Links from that
1948 page to external documents will not be followed. Actually, to download
1949 a single page and all its requisites (even if they exist on separate
1950 websites), and make sure the lot displays properly locally, this author
1951 likes to use a few options in addition to -p:
1952
1953 wget2 -E -H -k -K -p https://<site>/<document>
1954
1955 To finish off this topic, it’s worth knowing that Wget2’s idea of an
1956 external document link is any URL specified in an <A> tag, an <AREA>
1957 tag, or a <LINK> tag other than <LINK REL="stylesheet">.
1958
1959 --strict-comments
1960 Obsolete option for compatibility with Wget1.x. Wget2 always termi‐
1961 nates comments at the first occurrence of -->, as popular browsers do.
1962
1963 --robots
1964 Enable the Robots Exclusion Standard (default: on).
1965
1966 For each visited domain, follow rules specified in /robots.txt. You
1967 should respect the domain owner’s rules and turn this off only for very
1968 good reasons.
1969
1970 Whether enabled or disabled, the robots.txt file is downloaded and
1971 scanned for sitemaps. These are lists of pages / files available for
1972 download that not necessarily are available via recursive scanning.
1973
1974 Recursive Accept/Reject Options
1975 -A acclist, --accept=acclist, -R rejlist, --reject=rejlist
1976 Specify comma-separated lists of file name suffixes or patterns to ac‐
1977 cept or reject. Note that if any of the wildcard characters, *, ?, [,
1978 ], appear in an element of acclist or rejlist, it will be treated as a
1979 pattern, rather than a suffix. In this case, you have to enclose the
1980 pattern into quotes to prevent your shell from expanding it, like in -A
1981 "*.mp3" or -A '*.mp3'.
1982
1983 --accept-regex=urlregex, --reject-regex=urlregex
1984 Specify a regular expression to accept or reject file names.
1985
1986 --regex-type=regextype
1987 Specify the regular expression type. Possible types are posix or pcre.
1988 Note that to be able to use pcre type, wget2 has to be compiled with
1989 libpcre support.
1990
1991 --filter-urls
1992 Apply the accept and reject filters on the URL before starting a down‐
1993 load.
1994
1995 -D domain-list, --domains=domain-list
1996 Set domains to be followed. domain-list is a comma-separated list of
1997 domains. Note that it does not turn on -H.
1998
1999 --exclude-domains=domain-list
2000 Specify the domains that are not to be followed.
2001
2002 --follow-tags=list
2003 Wget2 has an internal table of HTML tag / attribute pairs that it con‐
2004 siders when looking for linked documents during a recursive retrieval.
2005 If a user wants only a subset of those tags to be considered, however,
2006 he or she should be specify such tags in a comma-separated list with
2007 this option.
2008
2009 --ignore-tags=list
2010 This is the opposite of the –follow-tags option. To skip certain HTML
2011 tags when recursively looking for documents to download, specify them
2012 in a comma-separated list.
2013
2014 In the past, this option was the best bet for downloading a single page
2015 and its requisites, using a command-line like:
2016
2017 wget2 --ignore-tags=a,area -H -k -K -r https://<site>/<document>
2018
2019 However, the author of this option came across a page with tags like “”
2020 and came to the realization that specifying tags to ignore was not
2021 enough. One can’t just tell Wget2 to ignore “”, because then
2022 stylesheets will not be downloaded. Now the best bet for downloading a
2023 single page and its requisites is the dedicated –page-requisites op‐
2024 tion.
2025
2026 --ignore-case
2027 Ignore case when matching files and directories. This influences the
2028 behavior of -R, -A, -I, and -X options. For example, with this option,
2029 -A “*.txt” will match file1.txt, but also file2.TXT, file3.TxT, and so
2030 on. The quotes in the example are to prevent the shell from expanding
2031 the pattern.
2032
2033 -H, --span-hosts
2034 Enable spanning across hosts when doing recursive retrieving.
2035
2036 -L, --relative [Not implemented yet]
2037 Follow relative links only. Useful for retrieving a specific home page
2038 without any distractions, not even those from the same hosts.
2039
2040 -I list, --include-directories=list
2041 Specify a comma-separated list of directories you wish to follow when
2042 downloading. Elements of the list may contain wildcards.
2043
2044 wget2 -r https://webpage.domain --include-directories=*/pub/*/
2045
2046 Please keep in mind that */pub/*/ is the same as /*/pub/*/ and that it
2047 matches directories, not strings. This means that */pub doesn’t affect
2048 files contained at e.g. /directory/something/pub but /pub/* matches ev‐
2049 ery subdir of /pub.
2050
2051 -X list, --exclude-directories=list
2052 Specify a comma-separated list of directories you wish to exclude from
2053 download. Elements of the list may contain wildcards.
2054
2055 wget2 -r https://gnu.org --exclude-directories=/software
2056
2057 -I / -X combinations
2058 Please be aware that the behavior of this combination of flags works
2059 slightly different than in wget1.x.
2060
2061 If -I is given first, the default is `exclude all'. If -X is given
2062 first, the default is `include all'.
2063
2064 Multiple -I/-X options are processed `first to last'. The last match
2065 is relevant.
2066
2067 Example: -I /pub -X /pub/trash would download all from /pub/ except from /pub/trash.
2068 Example: -X /pub -I /pub/important would download all except from /pub where only /pub/important would be downloaded.
2069
2070 To reset the list (e.g. to ignore -I/-X from .wgetrc files) use --no-
2071 include-directories or --no-exclude-directories.
2072
2073 -np, --no-parent
2074 Do not ever ascend to the parent directory when retrieving recursively.
2075 This is a useful option, since it guarantees that only the files below
2076 a certain hierarchy will be downloaded.
2077
2078 --filter-mime-type=list
2079 Specify a comma-separated list of MIME types that will be downloaded.
2080 Elements of list may contain wildcards. If a MIME type starts with the
2081 character `!' it won’t be downloaded, this is useful when trying to
2082 download something with exceptions. If server doesn’t specify the MIME
2083 type of a file it will be considered as `application/octet-stream'.
2084 For example, download everything except images:
2085
2086 wget2 -r https://<site>/<document> --filter-mime-type=*,\!image/*
2087
2088 It is also useful to download files that are compatible with an appli‐
2089 cation of your system. For instance, download every file that is com‐
2090 patible with LibreOffice Writer from a website using the recursive
2091 mode:
2092
2093 wget2 -r https://<site>/<document> --filter-mime-type=$(sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/,/g' /usr/share/applications/libreoffice-writer.desktop)
2094
2095 Plugin Options
2096 --list-plugins
2097 Print a list all available plugins and exit.
2098
2099 --local-plugin=file
2100 Load file as plugin.
2101
2102 --plugin=name
2103 Load a plugin with a given name from the configured plugin directories.
2104
2105 --plugin-dirs=directories
2106 Set plugin directories. directories is a comma-separated list of di‐
2107 rectories.
2108
2109 --plugin-help
2110 Print the help messages from all loaded plugins.
2111
2112 --plugin-opt=option
2113 Set a plugin specific command line option.
2114
2115 option is in the format <plugin_name>.<option>[=value].
2116
2118 Wget2 supports proxies for both HTTP and HTTPS retrievals. The stan‐
2119 dard way to specify proxy location, which Wget recognizes, is using the
2120 following environment variables:
2121
2122 http_proxy
2123
2124 https_proxy
2125
2126 If set, the http_proxy and https_proxy variables should contain the
2127 URLs of the proxies for HTTP and HTTPS connections respectively.
2128
2129 no_proxy
2130
2131 This variable should contain a comma-separated list of domain exten‐
2132 sions proxy should not be used for. For instance, if the value of
2133 no_proxy is .example.com, proxy will not be used to retrieve documents
2134 from *.example.com.
2135
2137 Wget2 may return one of several error codes if it encounters problems.
2138
2139 0 No problems occurred.
2140
2141 1 Generic error code.
2142
2143 2 Parse error. For instance, when parsing command-line options, the .wgetrc or .netrc...
2144
2145 3 File I/O error.
2146
2147 4 Network failure.
2148
2149 5 SSL verification failure.
2150
2151 6 Username/password authentication failure.
2152
2153 7 Protocol errors.
2154
2155 8 Server issued an error response.
2156
2157 9 Public key missing from keyring.
2158
2159 10 A Signature verification failed.
2160
2161 With the exceptions of 0 and 1, the lower-numbered exit codes take
2162 precedence over higher-numbered ones, when multiple types of errors are
2163 encountered.
2164
2166 Sometimes you may wish to permanently change the default behaviour of
2167 GNU Wget2. There is a better way to do this than setting an alias in
2168 your shell. GNU Wget2 allows you to set all options permanently
2169 through its startup up, .wget2rc.
2170
2171 While .wget2rc is the main initialization file used by GNU Wget2, it is
2172 not a good idea to store passwords in this file. This is because the
2173 startup file maybe publicly readable or backed up in version control.
2174 This is why Wget2 also reads the contents of $HOME/.netrc when re‐
2175 quired.
2176
2177 The .wget2rc file follows a very similar syntax to the .wgetrc that is
2178 read by GNU Wget. It varies in only those places where the command
2179 line options vary between Wget1.x and Wget2.
2180
2181 Wget2rc Location
2182 When initializing, Wget2 will attempt to read the “global” startup
2183 file, which is located at `/usr/local/etc/wget2rc' by default (or some
2184 prefix other than `/usr/local', if Wget2 was not installed there). The
2185 global startup file is useful for system administrators to enforce a
2186 default policy, such as setting the path to the certificate store,
2187 preloading a HSTS list, etc.
2188
2189 Then, Wget2 will look for the user’s initialization file. If the user
2190 has passed the --config command line option, Wget2 will try to load the
2191 file that it points to. If file does not exist, or if it cannot be
2192 read, Wget2 will make no further attempts to read any initialization
2193 files.
2194
2195 If the environment variable WGET2RC is set, Wget2 will try to load the
2196 file at this location. If the file does not exist, or if it cannot be
2197 read, Wget2 will make no further attempts to read an initialization
2198 file.
2199
2200 If, --config is not passed and WGET2RC is not set, Wget2 will attempt
2201 to load the user’s initialization file from a location as defined by
2202 the XDG Base Directory Specification. It will read the first, and only
2203 the first file it finds from the following locations:
2204
2205 1. $XDG_CONFIG_HOME/wget/wget2rc
2206
2207 2. $HOME/.config/wget/wget2rc
2208
2209 3. $HOME/.wget2rc
2210
2211 Having an initialization file at $HOME/.wget2rc is deprecated. If a
2212 file is found there, Wget2 will print a warning about it. Support for
2213 reading from this file will be removed in the future.
2214
2215 The fact that the user’s settings are loaded after the system-wide ones
2216 means that in case of a collision, the user’s wget2rc overrides the
2217 global wget2rc.
2218
2220 You are welcome to submit bug reports via the GNU Wget2 bug tracker
2221 (https://gitlab.com/gnuwget/wget2/issues).
2222
2223 Before actually submitting a bug report, please try to follow a few
2224 simple guidelines.
2225
2226 1. Please try to ascertain that the behavior you see really is a bug.
2227 If Wget2 crashes, it’s a bug. If Wget2 does not behave as document‐
2228 ed, it’s a bug. If things work strange, but you are not sure about
2229 the way they are supposed to work, it might well be a bug, but you
2230 might want to double-check the documentation and the mailing lists.
2231
2232 2. Try to repeat the bug in as simple circumstances as possible. E.g.
2233 if Wget2 crashes while downloading wget2 -rl0 -kKE -t5 --no-proxy
2234 https://example.com -o /tmp/log, you should try to see if the crash
2235 is repeatable, and if will occur with a simpler set of options. You
2236 might even try to start the download at the page where the crash oc‐
2237 curred to see if that page somehow triggered the crash.
2238
2239 Also, while I will probably be interested to know the contents of your
2240 .wgetrc file, just dumping it into the debug message is probably a bad
2241 idea. Instead, you should first try to see if the bug repeats with
2242 .wgetrc moved out of the way. Only if it turns out that .wgetrc set‐
2243 tings affect the bug, mail me the relevant parts of the file.
2244
2245 3. Please start Wget2 with -d option and send us the resulting output
2246 (or relevant parts thereof). If Wget2 was compiled without debug
2247 support, recompile it. It is much easier to trace bugs with debug
2248 support on.
2249
2250 Note: please make sure to remove any potentially sensitive information
2251 from the debug log before sending it to the bug address. The -d won’t
2252 go out of its way to collect sensitive information, but the log will
2253 contain a fairly complete transcript of Wget2’s communication with the
2254 server, which may include passwords and pieces of downloaded data.
2255 Since the bug address is publicly archived, you may assume that all bug
2256 reports are visible to the public.
2257
2258 4. If Wget2 has crashed, try to run it in a debugger, e.g. gdb `which
2259 wget` core and type “where” to get the backtrace. This may not work
2260 if the system administrator has disabled core files, but it is safe
2261 to try.
2262
2264 This is not the complete manual for GNU Wget. For more complete infor‐
2265 mation, including more detailed explanations of some of the options,
2266 and a number of commands available for use with .wgetrc files and the
2267 -e option, see the GNU Info entry for wget.
2268
2270 Wget2 written by Tim Rühsen <tim.ruehsen@gmx.de>
2271
2272 Wget 1.x originally written by Hrvoje Nikšić <hniksic@xemacs.org>
2273
2275 Copyright (C) 2012-2015 Tim Rühsen
2276
2277 Copyright (C) 2015-2021 Free Software Foundation, Inc.
2278
2279 Permission is granted to copy, distribute and/or modify this document
2280 under the terms of the GNU Free Documentation License, Version 1.3 or
2281 any later version published by the Free Software Foundation; with no
2282 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
2283 Texts. A copy of the license is included in the section entitled “GNU
2284 Free Documentation License”.
2285
2286
2287
2288GNU Wget2 User Manual WGET2(1)