WGET(1) GNU Wget WGET(1) NNAAMMEE Wget - The non-interactive network downloader. SSYYNNOOPPSSIISS wget [_o_p_t_i_o_n]... [_U_R_L]... DDEESSCCRRIIPPTTIIOONN GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. Wget is non-interactive, meaning that it can work in the background, while the user is not logged on. This allows you to start a retrieval and disconnect from the system, letting Wget finish the work. By con- trast, most of the Web browsers require constant user’s presence, which can be a great hindrance when transferring a lot of data. Wget can follow links in HTML and XHTML pages and create local ver- sions of remote web sites, fully recreating the directory structure of the original site. This is sometimes referred to as ‘‘recursive down- loading.’’ While doing that, Wget respects the Robot Exclusion Stan- dard (_/_r_o_b_o_t_s_._t_x_t). Wget can be instructed to convert the links in downloaded HTML files to the local files for offline viewing. Wget has been designed for robustness over slow or unstable network connections; if a download fails due to a network problem, it will keep retrying until the whole file has been retrieved. If the server supports regetting, it will instruct the server to continue the down- load from where it left off. OOPPTTIIOONNSS OOppttiioonn SSyynnttaaxx Since Wget uses GNU getopt to process command-line arguments, every option has a long form along with the short one. Long options are more convenient to remember, but take time to type. You may freely mix different option styles, or specify options after the command-line arguments. Thus you may write: wget -r --tries=10 http://fly.srk.fer.hr/ -o log The space between the option accepting an argument and the argument may be omitted. Instead --oo lloogg you can write --oolloogg. You may put several options that do not require arguments together, like: wget -drc This is a complete equivalent of: wget -d -r -c Since the options can be specified after the arguments, you may termi- nate them with ----. So the following will try to download URL --xx, reporting failure to _l_o_g: wget -o log -- -x The options that accept comma-separated lists all respect the conven- tion that specifying an empty list clears its value. This can be use- ful to clear the _._w_g_e_t_r_c settings. For instance, if your _._w_g_e_t_r_c sets "exclude_directories" to _/_c_g_i_-_b_i_n, the following example will first reset it, and then set it to exclude _/_~_n_o_b_o_d_y and _/_~_s_o_m_e_b_o_d_y. You can also clear the lists in _._w_g_e_t_r_c. wget -X ’’ -X /~nobody,/~somebody Most options that do not accept arguments are _b_o_o_l_e_a_n options, so named because their state can be captured with a yes-or-no (‘‘boolean’’) variable. For example, ----ffoollllooww--ffttpp tells Wget to fol- low FTP links from HTML files and, on the other hand, ----nnoo--gglloobb tells it not to perform file globbing on FTP URLs. A boolean option is either _a_f_f_i_r_m_a_t_i_v_e or _n_e_g_a_t_i_v_e (beginning with ----nnoo). All such options share several properties. Unless stated otherwise, it is assumed that the default behavior is the opposite of what the option accomplishes. For example, the docu- mented existence of ----ffoollllooww--ffttpp assumes that the default is to _n_o_t follow FTP links from HTML pages. Affirmative options can be negated by prepending the ----nnoo-- to the option name; negative options can be negated by omitting the ----nnoo-- prefix. This might seem superfluous---if the default for an affirma- tive option is to not do something, then why provide a way to explic- itly turn it off? But the startup file may in fact change the default. For instance, using "follow_ftp = off" in _._w_g_e_t_r_c makes Wget _n_o_t follow FTP links by default, and using ----nnoo--ffoollllooww--ffttpp is the only way to restore the factory default from the command line. BBaassiicc SSttaarrttuupp OOppttiioonnss --VV ----vveerrssiioonn Display the version of Wget. --hh ----hheellpp Print a help message describing all of Wget’s command-line options. --bb ----bbaacckkggrroouunndd Go to background immediately after startup. If no output file is specified via the --oo, output is redirected to _w_g_e_t_-_l_o_g. --ee _c_o_m_m_a_n_d ----eexxeeccuuttee _c_o_m_m_a_n_d Execute _c_o_m_m_a_n_d as if it were a part of _._w_g_e_t_r_c. A command thus invoked will be executed _a_f_t_e_r the commands in _._w_g_e_t_r_c, thus tak- ing precedence over them. If you need to specify more than one wgetrc command, use multiple instances of --ee. LLooggggiinngg aanndd IInnppuutt FFiillee OOppttiioonnss --oo _l_o_g_f_i_l_e ----oouuttppuutt--ffiillee==_l_o_g_f_i_l_e Log all messages to _l_o_g_f_i_l_e. The messages are normally reported to standard error. --aa _l_o_g_f_i_l_e ----aappppeenndd--oouuttppuutt==_l_o_g_f_i_l_e Append to _l_o_g_f_i_l_e. This is the same as --oo, only it appends to _l_o_g_f_i_l_e instead of overwriting the old log file. If _l_o_g_f_i_l_e does not exist, a new file is created. --dd ----ddeebbuugg Turn on debug output, meaning various information important to the developers of Wget if it does not work properly. Your system administrator may have chosen to compile Wget without debug sup- port, in which case --dd will not work. Please note that compiling with debug support is always safe---Wget compiled with the debug support will _n_o_t print any debug info unless requested with --dd. --qq ----qquuiieett Turn off Wget’s output. --vv ----vveerrbboossee Turn on verbose output, with all the available data. The default output is verbose. --nnvv ----nnoo--vveerrbboossee Turn off verbose without being completely quiet (use --qq for that), which means that error messages and basic information still get printed. --ii _f_i_l_e ----iinnppuutt--ffiillee==_f_i_l_e Read URLs from _f_i_l_e. If -- is specified as _f_i_l_e, URLs are read from the standard input. (Use ..//-- to read from a file literally named --.) If this function is used, no URLs need be present on the command line. If there are URLs both on the command line and in an input file, those on the command lines will be the first ones to be retrieved. The _f_i_l_e need not be an HTML document (but no harm if it is)---it is enough if the URLs are just listed sequentially. However, if you specify ----ffoorrccee--hhttmmll, the document will be regarded as hhttmmll. In that case you may have problems with rela- tive links, which you can solve either by adding "" to the documents or by specifying ----bbaassee==_u_r_l on the command line. --FF ----ffoorrccee--hhttmmll When input is read from a file, force it to be treated as an HTML file. This enables you to retrieve relative links from existing HTML files on your local disk, by adding "" to HTML, or using the ----bbaassee command-line option. --BB _U_R_L ----bbaassee==_U_R_L Prepends _U_R_L to relative links read from the file specified with the --ii option. DDoowwnnllooaadd OOppttiioonnss ----bbiinndd--aaddddrreessss==_A_D_D_R_E_S_S When making client TCP/IP connections, bind to _A_D_D_R_E_S_S on the local machine. _A_D_D_R_E_S_S may be specified as a hostname or IP address. This option can be useful if your machine is bound to multiple IPs. --tt _n_u_m_b_e_r ----ttrriieess==_n_u_m_b_e_r Set number of retries to _n_u_m_b_e_r. Specify 0 or iinnff for infinite retrying. The default is to retry 20 times, with the exception of fatal errors like ‘‘connection refused’’ or ‘‘not found’’ (404), which are not retried. --OO _f_i_l_e ----oouuttppuutt--ddooccuummeenntt==_f_i_l_e The documents will not be written to the appropriate files, but all will be concatenated together and written to _f_i_l_e. If -- is used as _f_i_l_e, documents will be printed to standard output, dis- abling link conversion. (Use ..//-- to print to a file literally named --.) Note that a combination with --kk is only well-defined for download- ing a single document. --nncc ----nnoo--cclloobbbbeerr If a file is downloaded more than once in the same directory, Wget’s behavior depends on a few options, including --nncc. In cer- tain cases, the local file will be _c_l_o_b_b_e_r_e_d, or overwritten, upon repeated download. In other cases it will be preserved. When running Wget without --NN, --nncc, or --rr, downloading the same file in the same directory will result in the original copy of _f_i_l_e being preserved and the second copy being named _f_i_l_e..11. If that file is downloaded yet again, the third copy will be named _f_i_l_e..22, and so on. When --nncc is specified, this behavior is sup- pressed, and Wget will refuse to download newer copies of _f_i_l_e. Therefore, ‘‘"no-clobber"’’ is actually a misnomer in this mode---it’s not clobbering that’s prevented (as the numeric suf- fixes were already preventing clobbering), but rather the multiple version saving that’s prevented. When running Wget with --rr, but without --NN or --nncc, re-downloading a file will result in the new copy simply overwriting the old. Adding --nncc will prevent this behavior, instead causing the origi- nal version to be preserved and any newer copies on the server to be ignored. When running Wget with --NN, with or without --rr, the decision as to whether or not to download a newer copy of a file depends on the local and remote timestamp and size of the file. --nncc may not be specified at the same time as --NN. Note that when --nncc is specified, files with the suffixes ..hhttmmll or ..hhttmm will be loaded from the local disk and parsed as if they had been retrieved from the Web. --cc ----ccoonnttiinnuuee Continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program. For instance: wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z If there is a file named _l_s_-_l_R_._Z in the current directory, Wget will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file. Note that you don’t need to specify this option if you just want the current invocation of Wget to retry downloading a file should the connection be lost midway through. This is the default behav- ior. --cc only affects resumption of downloads started _p_r_i_o_r to this invocation of Wget, and whose local files are still sitting around. Without --cc, the previous example would just download the remote file to _l_s_-_l_R_._Z_._1, leaving the truncated _l_s_-_l_R_._Z file alone. Beginning with Wget 1.7, if you use --cc on a non-empty file, and it turns out that the server does not support continued downloading, Wget will refuse to start the download from scratch, which would effectively ruin existing contents. If you really want the down- load to start from scratch, remove the file. Also beginning with Wget 1.7, if you use --cc on a file which is of equal size as the one on the server, Wget will refuse to download the file and print an explanatory message. The same happens when the file is smaller on the server than locally (presumably because it was changed on the server since your last download attempt)---because ‘‘continuing’’ is not meaningful, no download occurs. On the other side of the coin, while using --cc, any file that’s bigger on the server than locally will be considered an incomplete download and only "(length(remote) - length(local))" bytes will be downloaded and tacked onto the end of the local file. This behav- ior can be desirable in certain cases---for instance, you can use wwggeett --cc to download just the new portion that’s been appended to a data collection or log file. However, if the file is bigger on the server because it’s been _c_h_a_n_g_e_d, as opposed to just _a_p_p_e_n_d_e_d to, you’ll end up with a gar- bled file. Wget has no way of verifying that the local file is really a valid prefix of the remote file. You need to be espe- cially careful of this when using --cc in conjunction with --rr, since every file will be considered as an "incomplete download" candi- date. Another instance where you’ll get a garbled file if you try to use --cc is if you have a lame HTTP proxy that inserts a ‘‘transfer interrupted’’ string into the local file. In the future a ‘‘roll- back’’ option may be added to deal with this case. Note that --cc only works with FTP servers and with HTTP servers that support the "Range" header. ----pprrooggrreessss==_t_y_p_e Select the type of the progress indicator you wish to use. Legal indicators are ‘‘dot’’ and ‘‘bar’’. The ‘‘bar’’ indicator is used by default. It draws an ASCII progress bar graphics (a.k.a ‘‘thermometer’’ display) indicating the status of retrieval. If the output is not a TTY, the ‘‘dot’’ bar will be used by default. Use ----pprrooggrreessss==ddoott to switch to the ‘‘dot’’ display. It traces the retrieval by printing dots on the screen, each dot represent- ing a fixed amount of downloaded data. When using the dotted retrieval, you may also set the _s_t_y_l_e by specifying the type as ddoott::_s_t_y_l_e. Different styles assign differ- ent meaning to one dot. With the "default" style each dot repre- sents 1K, there are ten dots in a cluster and 50 dots in a line. The "binary" style has a more ‘‘computer’’-like orientation---8K dots, 16-dots clusters and 48 dots per line (which makes for 384K lines). The "mega" style is suitable for downloading very large files---each dot represents 64K retrieved, there are eight dots in a cluster, and 48 dots on each line (so each line contains 3M). Note that you can set the default style using the "progress" com- mand in _._w_g_e_t_r_c. That setting may be overridden from the command line. The exception is that, when the output is not a TTY, the ‘‘dot’’ progress will be favored over ‘‘bar’’. To force the bar output, use ----pprrooggrreessss==bbaarr::ffoorrccee. --NN ----ttiimmeessttaammppiinngg Turn on time-stamping. --SS ----sseerrvveerr--rreessppoonnssee Print the headers sent by HTTP servers and responses sent by FTP servers. ----ssppiiddeerr When invoked with this option, Wget will behave as a Web _s_p_i_d_e_r, which means that it will not download the pages, just check that they are there. For example, you can use Wget to check your book- marks: wget --spider --force-html -i bookmarks.html This feature needs much more work for Wget to get close to the functionality of real web spiders. --TT sseeccoonnddss ----ttiimmeeoouutt==_s_e_c_o_n_d_s Set the network timeout to _s_e_c_o_n_d_s seconds. This is equivalent to specifying ----ddnnss--ttiimmeeoouutt, ----ccoonnnneecctt--ttiimmeeoouutt, and ----rreeaadd--ttiimmeeoouutt, all at the same time. When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a time- out to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings. All timeout-related options accept decimal values, as well as sub- second values. For example, 00..11 seconds is a legal (though unwise) choice of timeout. Subsecond timeouts are useful for checking server response times or for testing network latency. ----ddnnss--ttiimmeeoouutt==_s_e_c_o_n_d_s Set the DNS lookup timeout to _s_e_c_o_n_d_s seconds. DNS lookups that don’t complete within the specified time will fail. By default, there is no timeout on DNS lookups, other than that implemented by system libraries. ----ccoonnnneecctt--ttiimmeeoouutt==_s_e_c_o_n_d_s Set the connect timeout to _s_e_c_o_n_d_s seconds. TCP connections that take longer to establish will be aborted. By default, there is no connect timeout, other than that implemented by system libraries. ----rreeaadd--ttiimmeeoouutt==_s_e_c_o_n_d_s Set the read (and write) timeout to _s_e_c_o_n_d_s seconds. The ‘‘time’’ of this timeout refers _i_d_l_e _t_i_m_e: if, at any point in the down- load, no data is received for more than the specified number of seconds, reading fails and the download is restarted. This option does not directly affect the duration of the entire download. Of course, the remote server may choose to terminate the connec- tion sooner than this option requires. The default read timeout is 900 seconds. ----lliimmiitt--rraattee==_a_m_o_u_n_t Limit the download speed to _a_m_o_u_n_t bytes per second. Amount may be expressed in bytes, kilobytes with the kk suffix, or megabytes with the mm suffix. For example, ----lliimmiitt--rraattee==2200kk will limit the retrieval rate to 20KB/s. This is useful when, for whatever rea- son, you don’t want Wget to consume the entire available band- width. This option allows the use of decimal numbers, usually in conjunc- tion with power suffixes; for example, ----lliimmiitt--rraattee==22..55kk is a legal value. Note that Wget implements the limiting by sleeping the appropriate amount of time after a network read that took less time than spec- ified by the rate. Eventually this strategy causes the TCP trans- fer to slow down to approximately the specified rate. However, it may take some time for this balance to be achieved, so don’t be surprised if limiting the rate doesn’t work well with very small files. --ww _s_e_c_o_n_d_s ----wwaaiitt==_s_e_c_o_n_d_s Wait the specified number of seconds between the retrievals. Use of this option is recommended, as it lightens the server load by making the requests less frequent. Instead of in seconds, the time can be specified in minutes using the "m" suffix, in hours using "h" suffix, or in days using "d" suffix. Specifying a large value for this option is useful if the network or the destination host is down, so that Wget can wait long enough to reasonably expect the network error to be fixed before the retry. ----wwaaiittrreettrryy==_s_e_c_o_n_d_s If you don’t want Wget to wait between _e_v_e_r_y retrieval, but only between retries of failed downloads, you can use this option. Wget will use _l_i_n_e_a_r _b_a_c_k_o_f_f, waiting 1 second after the first failure on a given file, then waiting 2 seconds after the second failure on that file, up to the maximum number of _s_e_c_o_n_d_s you specify. Therefore, a value of 10 will actually make Wget wait up to (1 + 2 + ... + 10) = 55 seconds per file. Note that this option is turned on by default in the global _w_g_e_t_r_c file. ----rraannddoomm--wwaaiitt Some web sites may perform log analysis to identify retrieval pro- grams such as Wget by looking for statistically significant simi- larities in the time between requests. This option causes the time between requests to vary between 0 and 2 * _w_a_i_t seconds, where _w_a_i_t was specified using the ----wwaaiitt option, in order to mask Wget’s presence from such analysis. A recent article in a publication devoted to development on a pop- ular consumer platform provided code to perform this analysis on the fly. Its author suggested blocking at the class C address level to ensure automated retrieval programs were blocked despite changing DHCP-supplied addresses. The ----rraannddoomm--wwaaiitt option was inspired by this ill-advised recom- mendation to block many unrelated users from a web site due to the actions of one. ----nnoo--pprrooxxyy Don’t use proxies, even if the appropriate *_proxy environment variable is defined. --QQ _q_u_o_t_a ----qquuoottaa==_q_u_o_t_a Specify download quota for automatic retrievals. The value can be specified in bytes (default), kilobytes (with kk suffix), or megabytes (with mm suffix). Note that quota will never affect downloading a single file. So if you specify wwggeett --QQ1100kk ffttpp::////wwuuaarrcchhiivvee..wwuussttll..eedduu//llss--llRR..ggzz, all of the _l_s_-_l_R_._g_z will be downloaded. The same goes even when sev- eral URLs are specified on the command-line. However, quota is respected when retrieving either recursively, or from an input file. Thus you may safely type wwggeett --QQ22mm --ii ssiitteess---download will be aborted when the quota is exceeded. Setting quota to 0 or to iinnff unlimits the download quota. ----nnoo--ddnnss--ccaacchhee Turn off caching of DNS lookups. Normally, Wget remembers the IP addresses it looked up from DNS so it doesn’t have to repeatedly contact the DNS server for the same (typically small) set of hosts it retrieves from. This cache exists in memory only; a new Wget run will contact DNS again. However, it has been reported that in some situations it is not desirable to cache host names, even for the duration of a short- running application like Wget. With this option Wget issues a new DNS lookup (more precisely, a new call to "gethostbyname" or "getaddrinfo") each time it makes a new connection. Please note that this option will _n_o_t affect caching that might be performed by the resolving library or by an external caching layer, such as NSCD. If you don’t understand exactly what this option does, you proba- bly won’t need it. ----rreessttrriicctt--ffiillee--nnaammeess==_m_o_d_e Change which characters found in remote URLs may show up in local file names generated from those URLs. Characters that are _r_e_s_t_r_i_c_t_e_d by this option are escaped, i.e. replaced with %%HHHH, where HHHH is the hexadecimal number that corresponds to the restricted character. By default, Wget escapes the characters that are not valid as part of file names on your operating system, as well as control charac- ters that are typically unprintable. This option is useful for changing these defaults, either because you are downloading to a non-native partition, or because you want to disable escaping of the control characters. When mode is set to ‘‘unix’’, Wget escapes the character // and the control characters in the ranges 0--31 and 128--159. This is the default on Unix-like OS’es. When mode is set to ‘‘windows’’, Wget escapes the characters \\, ││, //, ::, ??, "", **, <<, >>, and the control characters in the ranges 0--31 and 128--159. In addition to this, Wget in Windows mode uses ++ instead of :: to separate host and port in local file names, and uses @@ instead of ?? to separate the query portion of the file name from the rest. Therefore, a URL that would be saved as wwwwww..xxeemmaaccss..oorrgg::44330000//sseeaarrcchh..ppll??iinnppuutt==bbllaahh in Unix mode would be saved as wwwwww..xxeemmaaccss..oorrgg++44330000//sseeaarrcchh..ppll@@iinnppuutt==bbllaahh in Windows mode. This mode is the default on Windows. If you append ,,nnooccoonnttrrooll to the mode, as in uunniixx,,nnooccoonnttrrooll, escap- ing of the control characters is also switched off. You can use ----rreessttrriicctt--ffiillee--nnaammeess==nnooccoonnttrrooll to turn off escaping of control characters without affecting the choice of the OS to use as file name restriction mode. --44 ----iinneett44--oonnllyy --66 ----iinneett66--oonnllyy Force connecting to IPv4 or IPv6 addresses. With ----iinneett44--oonnllyy or --44, Wget will only connect to IPv4 hosts, ignoring AAAA records in DNS, and refusing to connect to IPv6 addresses specified in URLs. Conversely, with ----iinneett66--oonnllyy or --66, Wget will only connect to IPv6 hosts and ignore A records and IPv4 addresses. Neither options should be needed normally. By default, an IPv6-aware Wget will use the address family specified by the host’s DNS record. If the DNS responds with both IPv4 and IPv6 addresses, Wget will them in sequence until it finds one it can connect to. (Also see "--prefer-family" option described below.) These options can be used to deliberately force the use of IPv4 or IPv6 address families on dual family systems, usually to aid debugging or to deal with broken network configuration. Only one of ----iinneett66--oonnllyy and ----iinneett44--oonnllyy may be specified at the same time. Neither option is available in Wget compiled without IPv6 support. ----pprreeffeerr--ffaammiillyy==IIPPvv44//IIPPvv66//nnoonnee When given a choice of several addresses, connect to the addresses with specified address family first. IPv4 addresses are preferred by default. This avoids spurious errors and connect attempts when accessing hosts that resolve to both IPv6 and IPv4 addresses from IPv4 net- works. For example, wwwwww..kkaammee..nneett resolves to 22000011::220000::00::88000022::220033::4477ffff::ffeeaa55::33008855 and to 220033..117788..114411..119944. When the preferred family is "IPv4", the IPv4 address is used first; when the preferred family is "IPv6", the IPv6 address is used first; if the specified value is "none", the address order returned by DNS is used without change. Unlike --44 and --66, this option doesn’t inhibit access to any address family, it only changes the _o_r_d_e_r in which the addresses are accessed. Also note that the reordering performed by this option is _s_t_a_b_l_e---it doesn’t affect order of addresses of the same family. That is, the relative order of all IPv4 addresses and of all IPv6 addresses remains intact in all cases. ----rreettrryy--ccoonnnnrreeffuusseedd Consider ‘‘connection refused’’ a transient error and try again. Normally Wget gives up on a URL when it is unable to connect to the site because failure to connect is taken as a sign that the server is not running at all and that retries would not help. This option is for mirroring unreliable sites whose servers tend to disappear for short periods of time. ----uusseerr==_u_s_e_r ----ppaasssswwoorrdd==_p_a_s_s_w_o_r_d Specify the username _u_s_e_r and password _p_a_s_s_w_o_r_d for both FTP and HTTP file retrieval. These parameters can be overridden using the ----ffttpp--uusseerr and ----ffttpp--ppaasssswwoorrdd options for FTP connections and the ----hhttttpp--uusseerr and ----hhttttpp--ppaasssswwoorrdd options for HTTP connections. DDiirreeccttoorryy OOppttiioonnss --nndd ----nnoo--ddiirreeccttoorriieess Do not create a hierarchy of directories when retrieving recur- sively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the filenames will get extensions ..nn). --xx ----ffoorrccee--ddiirreeccttoorriieess The opposite of --nndd---create a hierarchy of directories, even if one would not have been created otherwise. E.g. wwggeett --xx hhttttpp::////ffllyy..ssrrkk..ffeerr..hhrr//rroobboottss..ttxxtt will save the downloaded file to _f_l_y_._s_r_k_._f_e_r_._h_r_/_r_o_b_o_t_s_._t_x_t. --nnHH ----nnoo--hhoosstt--ddiirreeccttoorriieess Disable generation of host-prefixed directories. By default, invoking Wget with --rr hhttttpp::////ffllyy..ssrrkk..ffeerr..hhrr// will create a structure of directories beginning with _f_l_y_._s_r_k_._f_e_r_._h_r_/. This option disables such behavior. ----pprroottooccooll--ddiirreeccttoorriieess Use the protocol name as a directory component of local file names. For example, with this option, wwggeett --rr hhttttpp::////_h_o_s_t will save to hhttttpp//_h_o_s_t//...... rather than just to _h_o_s_t//....... ----ccuutt--ddiirrss==_n_u_m_b_e_r Ignore _n_u_m_b_e_r directory components. This is useful for getting a fine-grained control over the directory where recursive retrieval will be saved. Take, for example, the directory at ffttpp::////ffttpp..xxeemmaaccss..oorrgg//ppuubb//xxeemmaaccss//. If you retrieve it with --rr, it will be saved locally under _f_t_p_._x_e_m_a_c_s_._o_r_g_/_p_u_b_/_x_e_m_a_c_s_/. While the --nnHH option can remove the _f_t_p_._x_e_m_a_c_s_._o_r_g_/ part, you are still stuck with _p_u_b_/_x_e_m_a_c_s. This is where ----ccuutt--ddiirrss comes in handy; it makes Wget not ‘‘see’’ _n_u_m_b_e_r remote directory components. Here are several examples of how ----ccuutt--ddiirrss option works. No options -> ftp.xemacs.org/pub/xemacs/ -nH -> pub/xemacs/ -nH --cut-dirs=1 -> xemacs/ -nH --cut-dirs=2 -> . --cut-dirs=1 -> ftp.xemacs.org/xemacs/ ... If you just want to get rid of the directory structure, this option is similar to a combination of --nndd and --PP. However, unlike --nndd, ----ccuutt--ddiirrss does not lose with subdirectories---for instance, with --nnHH ----ccuutt--ddiirrss==11, a _b_e_t_a_/ subdirectory will be placed to _x_e_m_a_c_s_/_b_e_t_a, as one would expect. --PP _p_r_e_f_i_x ----ddiirreeccttoorryy--pprreeffiixx==_p_r_e_f_i_x Set directory prefix to _p_r_e_f_i_x. The _d_i_r_e_c_t_o_r_y _p_r_e_f_i_x is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is .. (the current directory). HHTTTTPP OOppttiioonnss --EE ----hhttmmll--eexxtteennssiioonn If a file of type aapppplliiccaattiioonn//xxhhttmmll++xxmmll or tteexxtt//hhttmmll is downloaded and the URL does not end with the regexp \\..[[HHhh]][[TTtt]][[MMmm]][[LLll]]??, this option will cause the suffix ..hhttmmll to be appended to the local filename. This is useful, for instance, when you’re mirroring a remote site that uses ..aasspp pages, but you want the mirrored pages to be viewable on your stock Apache server. Another good use for this is when you’re downloading CGI-generated materials. A URL like hhttttpp::////ssiittee..ccoomm//aarrttiiccllee..ccggii??2255 will be saved as _a_r_t_i_- _c_l_e_._c_g_i_?_2_5_._h_t_m_l. Note that filenames changed in this way will be re-downloaded every time you re-mirror a site, because Wget can’t tell that the local _X_._h_t_m_l file corresponds to remote URL _X (since it doesn’t yet know that the URL produces output of type tteexxtt//hhttmmll or aappppllii-- ccaattiioonn//xxhhttmmll++xxmmll. To prevent this re-downloading, you must use --kk and --KK so that the original version of the file will be saved as _X_._o_r_i_g. ----hhttttpp--uusseerr==_u_s_e_r ----hhttttpp--ppaasssswwoorrdd==_p_a_s_s_w_o_r_d Specify the username _u_s_e_r and password _p_a_s_s_w_o_r_d on an HTTP server. According to the type of the challenge, Wget will encode them using either the "basic" (insecure) or the "digest" authentication scheme. Another way to specify username and password is in the URL itself. Either method reveals your password to anyone who bothers to run "ps". To prevent the passwords from being seen, store them in _._w_g_e_t_r_c or _._n_e_t_r_c, and make sure to protect those files from other users with "chmod". If the passwords are really important, do not leave them lying in those files either---edit the files and delete them after Wget has started the download. ----nnoo--ccaacchhee Disable server-side cache. In this case, Wget will send the remote server an appropriate directive (PPrraaggmmaa:: nnoo--ccaacchhee) to get the file from the remote service, rather than returning the cached version. This is especially useful for retrieving and flushing out-of-date documents on proxy servers. Caching is allowed by default. ----nnoo--ccooookkiieess Disable the use of cookies. Cookies are a mechanism for maintain- ing server-side state. The server sends the client a cookie using the "Set-Cookie" header, and the client responds with the same cookie upon further requests. Since cookies allow the server own- ers to keep track of visitors and for sites to exchange this information, some consider them a breach of privacy. The default is to use cookies; however, _s_t_o_r_i_n_g cookies is not on by default. ----llooaadd--ccooookkiieess _f_i_l_e Load cookies from _f_i_l_e before the first HTTP retrieval. _f_i_l_e is a textual file in the format originally used by Netscape’s _c_o_o_k_- _i_e_s_._t_x_t file. You will typically use this option when mirroring sites that require that you be logged in to access some or all of their con- tent. The login process typically works by the web server issuing an HTTP cookie upon receiving and verifying your credentials. The cookie is then resent by the browser when accessing that part of the site, and so proves your identity. Mirroring such a site requires Wget to send the same cookies your browser sends when communicating with the site. This is achieved by ----llooaadd--ccooookkiieess---simply point Wget to the location of the _c_o_o_k_- _i_e_s_._t_x_t file, and it will send the same cookies your browser would send in the same situation. Different browsers keep textual cookie files in different locations: NNeettssccaappee 44..xx.. The cookies are in _~_/_._n_e_t_s_c_a_p_e_/_c_o_o_k_i_e_s_._t_x_t. MMoozziillllaa aanndd NNeettssccaappee 66..xx.. Mozilla’s cookie file is also named _c_o_o_k_i_e_s_._t_x_t, located some- where under _~_/_._m_o_z_i_l_l_a, in the directory of your profile. The full path usually ends up looking somewhat like _~_/_._m_o_z_i_l_l_a_/_d_e_f_a_u_l_t_/_s_o_m_e_-_w_e_i_r_d_-_s_t_r_i_n_g_/_c_o_o_k_i_e_s_._t_x_t. IInntteerrnneett EExxpplloorreerr.. You can produce a cookie file Wget can use by using the File menu, Import and Export, Export Cookies. This has been tested with Internet Explorer 5; it is not guaranteed to work with earlier versions. OOtthheerr bbrroowwsseerrss.. If you are using a different browser to create your cookies, ----llooaadd--ccooookkiieess will only work if you can locate or produce a cookie file in the Netscape format that Wget expects. If you cannot use ----llooaadd--ccooookkiieess, there might still be an alterna- tive. If your browser supports a ‘‘cookie manager’’, you can use it to view the cookies used when accessing the site you’re mirror- ing. Write down the name and value of the cookie, and manually instruct Wget to send those cookies, bypassing the ‘‘official’’ cookie support: wget --no-cookies --header "Cookie: =" ----ssaavvee--ccooookkiieess _f_i_l_e Save cookies to _f_i_l_e before exiting. This will not save cookies that have expired or that have no expiry time (so-called ‘‘session cookies’’), but also see ----kkeeeepp--sseessssiioonn--ccooookkiieess. ----kkeeeepp--sseessssiioonn--ccooookkiieess When specified, causes ----ssaavvee--ccooookkiieess to also save session cook- ies. Session cookies are normally not saved because they are meant to be kept in memory and forgotten when you exit the browser. Saving them is useful on sites that require you to log in or to visit the home page before you can access some pages. With this option, multiple Wget runs are considered a single browser session as far as the site is concerned. Since the cookie file format does not normally carry session cook- ies, Wget marks them with an expiry timestamp of 0. Wget’s ----llooaadd--ccooookkiieess recognizes those as session cookies, but it might confuse other browsers. Also note that cookies so loaded will be treated as other session cookies, which means that if you want ----ssaavvee--ccooookkiieess to preserve them again, you must use ----kkeeeepp--sseess-- ssiioonn--ccooookkiieess again. ----iiggnnoorree--lleennggtthh Unfortunately, some HTTP servers (CGI programs, to be more pre- cise) send out bogus "Content-Length" headers, which makes Wget go wild, as it thinks not all the document was retrieved. You can spot this syndrome if Wget retries getting the same document again and again, each time claiming that the (otherwise normal) connec- tion has closed on the very same byte. With this option, Wget will ignore the "Content-Length" header---as if it never existed. ----hheeaaddeerr==_h_e_a_d_e_r_-_l_i_n_e Send _h_e_a_d_e_r_-_l_i_n_e along with the rest of the headers in each HTTP request. The supplied header is sent as-is, which means it must contain name and value separated by colon, and must not contain newlines. You may define more than one additional header by specifying ----hheeaaddeerr more than once. wget --header=’Accept-Charset: iso-8859-2’ \ --header=’Accept-Language: hr’ \ http://fly.srk.fer.hr/ Specification of an empty string as the header value will clear all previous user-defined headers. As of Wget 1.10, this option can be used to override headers oth- erwise generated automatically. This example instructs Wget to connect to localhost, but to specify ffoooo..bbaarr in the "Host" header: wget --header="Host: foo.bar" http://localhost/ In versions of Wget prior to 1.10 such use of ----hheeaaddeerr caused sending of duplicate headers. ----pprrooxxyy--uusseerr==_u_s_e_r ----pprrooxxyy--ppaasssswwoorrdd==_p_a_s_s_w_o_r_d Specify the username _u_s_e_r and password _p_a_s_s_w_o_r_d for authentication on a proxy server. Wget will encode them using the "basic" authentication scheme. Security considerations similar to those with ----hhttttpp--ppaasssswwoorrdd per- tain here as well. ----rreeffeerreerr==_u_r_l Include ‘Referer: _u_r_l’ header in HTTP request. Useful for retrieving documents with server-side processing that assume they are always being retrieved by interactive web browsers and only come out properly when Referer is set to one of the pages that point to them. ----ssaavvee--hheeaaddeerrss Save the headers sent by the HTTP server to the file, preceding the actual contents, with an empty line as the separator. --UU _a_g_e_n_t_-_s_t_r_i_n_g ----uusseerr--aaggeenntt==_a_g_e_n_t_-_s_t_r_i_n_g Identify as _a_g_e_n_t_-_s_t_r_i_n_g to the HTTP server. The HTTP protocol allows the clients to identify themselves using a "User-Agent" header field. This enables distinguishing the WWW software, usually for statistical purposes or for tracing of pro- tocol violations. Wget normally identifies as WWggeett//_v_e_r_s_i_o_n, _v_e_r_- _s_i_o_n being the current version number of Wget. However, some sites have been known to impose the policy of tai- loring the output according to the "User-Agent"-supplied informa- tion. While this is not such a bad idea in theory, it has been abused by servers denying information to clients other than (his- torically) Netscape or, more frequently, Microsoft Internet Explorer. This option allows you to change the "User-Agent" line issued by Wget. Use of this option is discouraged, unless you really know what you are doing. Specifying empty user agent with ----uusseerr--aaggeenntt=="""" instructs Wget not to send the "User-Agent" header in HTTP requests. ----ppoosstt--ddaattaa==_s_t_r_i_n_g ----ppoosstt--ffiillee==_f_i_l_e Use POST as the method for all HTTP requests and send the speci- fied data in the request body. "--post-data" sends _s_t_r_i_n_g as data, whereas "--post-file" sends the contents of _f_i_l_e. Other than that, they work in exactly the same way. Please be aware that Wget needs to know the size of the POST data in advance. Therefore the argument to "--post-file" must be a regular file; specifying a FIFO or something like _/_d_e_v_/_s_t_d_i_n won’t work. It’s not quite clear how to work around this limitation inherent in HTTP/1.0. Although HTTP/1.1 introduces _c_h_u_n_k_e_d trans- fer that doesn’t require knowing the request length in advance, a client can’t use chunked unless it knows it’s talking to an HTTP/1.1 server. And it can’t know that until it receives a response, which in turn requires the request to have been com- pleted -- a chicken-and-egg problem. Note: if Wget is redirected after the POST request is completed, it will not send the POST data to the redirected URL. This is because URLs that process POST often respond with a redirection to a regular page, which does not desire or accept POST. It is not completely clear that this behavior is optimal; if it doesn’t work out, it might be changed in the future. This example shows how to log to a server using POST and then pro- ceed to download the desired pages, presumably only accessible to authorized users: # Log in to the server. This can be done only once. wget --save-cookies cookies.txt \ --post-data ’user=foo&password=bar’ \ http://server.com/auth.php # Now grab the page or pages we care about. wget --load-cookies cookies.txt \ -p http://server.com/interesting/article.php If the server is using session cookies to track user authentica- tion, the above will not work because ----ssaavvee--ccooookkiieess will not save them (and neither will browsers) and the _c_o_o_k_i_e_s_._t_x_t file will be empty. In that case use ----kkeeeepp--sseessssiioonn--ccooookkiieess along with ----ssaavvee--ccooookkiieess to force saving of session cookies. HHTTTTPPSS ((SSSSLL//TTLLSS)) OOppttiioonnss To support encrypted HTTP (HTTPS) downloads, Wget must be compiled with an external SSL library, currently OpenSSL. If Wget is compiled without SSL support, none of these options are available. ----sseeccuurree--pprroottooccooll==_p_r_o_t_o_c_o_l Choose the secure protocol to be used. Legal values are aauuttoo, SSSSLLvv22, SSSSLLvv33, and TTLLSSvv11. If aauuttoo is used, the SSL library is given the liberty of choosing the appropriate protocol automati- cally, which is achieved by sending an SSLv2 greeting and announc- ing support for SSLv3 and TLSv1. This is the default. Specifying SSSSLLvv22, SSSSLLvv33, or TTLLSSvv11 forces the use of the corre- sponding protocol. This is useful when talking to old and buggy SSL server implementations that make it hard for OpenSSL to choose the correct protocol version. Fortunately, such servers are quite rare. ----nnoo--cchheecckk--cceerrttiiffiiccaattee Don’t check the server certificate against the available certifi- cate authorities. Also don’t require the URL host name to match the common name presented by the certificate. As of Wget 1.10, the default is to verify the server’s certificate against the recognized certificate authorities, breaking the SSL handshake and aborting the download if the verification fails. Although this provides more secure downloads, it does break inter- operability with some sites that worked with previous Wget ver- sions, particularly those using self-signed, expired, or otherwise invalid certificates. This option forces an ‘‘insecure’’ mode of operation that turns the certificate verification errors into warnings and allows you to proceed. If you encounter ‘‘certificate verification’’ errors or ones say- ing that ‘‘common name doesn’t match requested host name’’, you can use this option to bypass the verification and proceed with the download. _O_n_l_y _u_s_e _t_h_i_s _o_p_t_i_o_n _i_f _y_o_u _a_r_e _o_t_h_e_r_w_i_s_e _c_o_n_v_i_n_c_e_d _o_f _t_h_e _s_i_t_e_’_s _a_u_t_h_e_n_t_i_c_i_t_y_, _o_r _i_f _y_o_u _r_e_a_l_l_y _d_o_n_’_t _c_a_r_e _a_b_o_u_t _t_h_e _v_a_l_i_d_i_t_y _o_f _i_t_s _c_e_r_t_i_f_i_c_a_t_e_. It is almost always a bad idea not to check the certificates when transmitting confidential or impor- tant data. ----cceerrttiiffiiccaattee==_f_i_l_e Use the client certificate stored in _f_i_l_e. This is needed for servers that are configured to require certificates from the clients that connect to them. Normally a certificate is not required and this switch is optional. ----cceerrttiiffiiccaattee--ttyyppee==_t_y_p_e Specify the type of the client certificate. Legal values are PPEEMM (assumed by default) and DDEERR, also known as AASSNN11. ----pprriivvaattee--kkeeyy==_f_i_l_e Read the private key from _f_i_l_e. This allows you to provide the private key in a file separate from the certificate. ----pprriivvaattee--kkeeyy--ttyyppee==_t_y_p_e Specify the type of the private key. Accepted values are PPEEMM (the default) and DDEERR. ----ccaa--cceerrttiiffiiccaattee==_f_i_l_e Use _f_i_l_e as the file with the bundle of certificate authorities (‘‘CA’’) to verify the peers. The certificates must be in PEM format. Without this option Wget looks for CA certificates at the system- specified locations, chosen at OpenSSL installation time. ----ccaa--ddiirreeccttoorryy==_d_i_r_e_c_t_o_r_y Specifies directory containing CA certificates in PEM format. Each file contains one CA certificate, and the file name is based on a hash value derived from the certificate. This is achieved by processing a certificate directory with the "c_rehash" utility supplied with OpenSSL. Using ----ccaa--ddiirreeccttoorryy is more efficient than ----ccaa--cceerrttiiffiiccaattee when many certificates are installed because it allows Wget to fetch certificates on demand. Without this option Wget looks for CA certificates at the system- specified locations, chosen at OpenSSL installation time. ----rraannddoomm--ffiillee==_f_i_l_e Use _f_i_l_e as the source of random data for seeding the pseudo-ran- dom number generator on systems without _/_d_e_v_/_r_a_n_d_o_m. On such systems the SSL library needs an external source of ran- domness to initialize. Randomness may be provided by EGD (see ----eeggdd--ffiillee below) or read from an external source specified by the user. If this option is not specified, Wget looks for random data in $RANDFILE or, if that is unset, in _$_H_O_M_E_/_._r_n_d. If none of those are available, it is likely that SSL encryption will not be usable. If you’re getting the ‘‘Could not seed OpenSSL PRNG; disabling SSL.’’ error, you should provide random data using some of the methods described above. ----eeggdd--ffiillee==_f_i_l_e Use _f_i_l_e as the EGD socket. EGD stands for _E_n_t_r_o_p_y _G_a_t_h_e_r_i_n_g _D_a_e_- _m_o_n, a user-space program that collects data from various unpre- dictable system sources and makes it available to other programs that might need it. Encryption software, such as the SSL library, needs sources of non-repeating randomness to seed the random num- ber generator used to produce cryptographically strong keys. OpenSSL allows the user to specify his own source of entropy using the "RAND_FILE" environment variable. If this variable is unset, or if the specified file does not produce enough randomness, OpenSSL will read random data from EGD socket specified using this option. If this option is not specified (and the equivalent startup com- mand is not used), EGD is never contacted. EGD is not needed on modern Unix systems that support _/_d_e_v_/_r_a_n_d_o_m. FFTTPP OOppttiioonnss ----ffttpp--uusseerr==_u_s_e_r ----ffttpp--ppaasssswwoorrdd==_p_a_s_s_w_o_r_d Specify the username _u_s_e_r and password _p_a_s_s_w_o_r_d on an FTP server. Without this, or the corresponding startup option, the password defaults to --wwggeett@@, normally used for anonymous FTP. Another way to specify username and password is in the URL itself. Either method reveals your password to anyone who bothers to run "ps". To prevent the passwords from being seen, store them in _._w_g_e_t_r_c or _._n_e_t_r_c, and make sure to protect those files from other users with "chmod". If the passwords are really important, do not leave them lying in those files either---edit the files and delete them after Wget has started the download. ----nnoo--rreemmoovvee--lliissttiinngg Don’t remove the temporary _._l_i_s_t_i_n_g files generated by FTP retrievals. Normally, these files contain the raw directory list- ings received from FTP servers. Not removing them can be useful for debugging purposes, or when you want to be able to easily check on the contents of remote server directories (e.g. to verify that a mirror you’re running is complete). Note that even though Wget writes to a known filename for this file, this is not a security hole in the scenario of a user making _._l_i_s_t_i_n_g a symbolic link to _/_e_t_c_/_p_a_s_s_w_d or something and asking "root" to run Wget in his or her directory. Depending on the options used, either Wget will refuse to write to _._l_i_s_t_i_n_g, making the globbing/recursion/time-stamping operation fail, or the sym- bolic link will be deleted and replaced with the actual _._l_i_s_t_i_n_g file, or the listing will be written to a _._l_i_s_t_i_n_g_._n_u_m_b_e_r file. Even though this situation isn’t a problem, though, "root" should never run Wget in a non-trusted user’s directory. A user could do something as simple as linking _i_n_d_e_x_._h_t_m_l to _/_e_t_c_/_p_a_s_s_w_d and ask- ing "root" to run Wget with --NN or --rr so the file will be overwrit- ten. ----nnoo--gglloobb Turn off FTP globbing. Globbing refers to the use of shell-like special characters (_w_i_l_d_c_a_r_d_s), like **, ??, [[ and ]] to retrieve more than one file from the same directory at once, like: wget ftp://gnjilux.srk.fer.hr/*.msg By default, globbing will be turned on if the URL contains a glob- bing character. This option may be used to turn globbing on or off permanently. You may have to quote the URL to protect it from being expanded by your shell. Globbing makes Wget look for a directory listing, which is system-specific. This is why it currently works only with Unix FTP servers (and the ones emulating Unix "ls" output). ----nnoo--ppaassssiivvee--ffttpp Disable the use of the _p_a_s_s_i_v_e FTP transfer mode. Passive FTP mandates that the client connect to the server to establish the data connection rather than the other way around. If the machine is connected to the Internet directly, both passive and active FTP should work equally well. Behind most firewall and NAT configurations passive FTP has a better chance of working. However, in some rare firewall configurations, active FTP actually works when passive FTP doesn’t. If you suspect this to be the case, use this option, or set "passive_ftp=off" in your init file. ----rreettrr--ssyymmlliinnkkss Usually, when retrieving FTP directories recursively and a sym- bolic link is encountered, the linked-to file is not downloaded. Instead, a matching symbolic link is created on the local filesys- tem. The pointed-to file will not be downloaded unless this recursive retrieval would have encountered it separately and down- loaded it anyway. When ----rreettrr--ssyymmlliinnkkss is specified, however, symbolic links are traversed and the pointed-to files are retrieved. At this time, this option does not cause Wget to traverse symlinks to directo- ries and recurse through them, but in the future it should be enhanced to do this. Note that when retrieving a file (not a directory) because it was specified on the command-line, rather than because it was recursed to, this option has no effect. Symbolic links are always tra- versed in this case. ----nnoo--hhttttpp--kkeeeepp--aalliivvee Turn off the ‘‘keep-alive’’ feature for HTTP downloads. Normally, Wget asks the server to keep the connection open so that, when you download more than one document from the same server, they get transferred over the same TCP connection. This saves time and at the same time reduces the load on the server. This option is useful when, for some reason, persistent (keep-alive) connections don’t work for you, for example due to a server bug or due to the inability of server-side scripts to cope with the connections. RReeccuurrssiivvee RReettrriieevvaall OOppttiioonnss --rr ----rreeccuurrssiivvee Turn on recursive retrieving. --ll _d_e_p_t_h ----lleevveell==_d_e_p_t_h Specify recursion maximum depth level _d_e_p_t_h. The default maximum depth is 5. ----ddeelleettee--aafftteerr This option tells Wget to delete every single file it downloads, _a_f_t_e_r having done so. It is useful for pre-fetching popular pages through a proxy, e.g.: wget -r -nd --delete-after http://whatever.com/~popular/page/ The --rr option is to retrieve recursively, and --nndd to not create directories. Note that ----ddeelleettee--aafftteerr deletes files on the local machine. It does not issue the DDEELLEE command to remote FTP sites, for instance. Also note that when ----ddeelleettee--aafftteerr is specified, ----ccoonnvveerrtt--lliinnkkss is ignored, so ..oorriigg files are simply not created in the first place. --kk ----ccoonnvveerrtt--lliinnkkss After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc. Each link will be changed in one of the two ways: * The links to files that have been downloaded by Wget will be changed to refer to the file they point to as a relative link. Example: if the downloaded file _/_f_o_o_/_d_o_c_._h_t_m_l links to _/_b_a_r_/_i_m_g_._g_i_f, also downloaded, then the link in _d_o_c_._h_t_m_l will be modified to point to ....//bbaarr//iimmgg..ggiiff. This kind of trans- formation works reliably for arbitrary combinations of direc- tories. * The links to files that have not been downloaded by Wget will be changed to include host name and absolute path of the loca- tion they point to. Example: if the downloaded file _/_f_o_o_/_d_o_c_._h_t_m_l links to _/_b_a_r_/_i_m_g_._g_i_f (or to _._._/_b_a_r_/_i_m_g_._g_i_f), then the link in _d_o_c_._h_t_m_l will be modified to point to _h_t_t_p_:_/_/_h_o_s_t_n_a_m_e_/_b_a_r_/_i_m_g_._g_i_f. Because of this, local browsing works reliably: if a linked file was downloaded, the link will refer to its local name; if it was not downloaded, the link will refer to its full Internet address rather than presenting a broken link. The fact that the former links are converted to relative links ensures that you can move the downloaded hierarchy to another directory. Note that only at the end of the download can Wget know which links have been downloaded. Because of that, the work done by --kk will be performed at the end of all the downloads. --KK ----bbaacckkuupp--ccoonnvveerrtteedd When converting a file, back up the original version with a ..oorriigg suffix. Affects the behavior of --NN. --mm ----mmiirrrroorr Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to --rr --NN --ll iinnff ----nnoo--rreemmoovvee--lliissttiinngg. --pp ----ppaaggee--rreeqquuiissiitteess This option causes Wget to download all the files that are neces- sary to properly display a given HTML page. This includes such things as inlined images, sounds, and referenced stylesheets. Ordinarily, when downloading a single HTML page, any requisite documents that may be needed to display it properly are not down- loaded. Using --rr together with --ll can help, but since Wget does not ordinarily distinguish between external and inlined documents, one is generally left with ‘‘leaf documents’’ that are missing their requisites. For instance, say document _1_._h_t_m_l contains an "" tag refer- encing _1_._g_i_f and an "" tag pointing to external document _2_._h_t_m_l. Say that _2_._h_t_m_l is similar but that its image is _2_._g_i_f and it links to _3_._h_t_m_l. Say this continues up to some arbitrarily high number. If one executes the command: wget -r -l 2 http:///1.html then _1_._h_t_m_l, _1_._g_i_f, _2_._h_t_m_l, _2_._g_i_f, and _3_._h_t_m_l will be downloaded. As you can see, _3_._h_t_m_l is without its requisite _3_._g_i_f because Wget is simply counting the number of hops (up to 2) away from _1_._h_t_m_l in order to determine where to stop the recursion. However, with this command: wget -r -l 2 -p http:///1.html all the above files _a_n_d _3_._h_t_m_l’s requisite _3_._g_i_f will be down- loaded. Similarly, wget -r -l 1 -p http:///1.html will cause _1_._h_t_m_l, _1_._g_i_f, _2_._h_t_m_l, and _2_._g_i_f to be downloaded. One might think that: wget -r -l 0 -p http:///1.html would download just _1_._h_t_m_l and _1_._g_i_f, but unfortunately this is not the case, because --ll 00 is equivalent to --ll iinnff---that is, infinite recursion. To download a single HTML page (or a handful of them, all specified on the command-line or in a --ii URL input file) and its (or their) requisites, simply leave off --rr and --ll: wget -p http:///1.html Note that Wget will behave as if --rr had been specified, but only that single page and its requisites will be downloaded. Links from that page to external documents will not be followed. Actu- ally, to download a single page and all its requisites (even if they exist on separate websites), and make sure the lot displays properly locally, this author likes to use a few options in addi- tion to --pp: wget -E -H -k -K -p http:/// To finish off this topic, it’s worth knowing that Wget’s idea of an external document link is any URL specified in an "" tag, an "" tag, or a "" tag other than "". ----ssttrriicctt--ccoommmmeennttss Turn on strict parsing of HTML comments. The default is to termi- nate comments at the first occurrence of ---->>. According to specifications, HTML comments are expressed as SGML _d_e_c_l_a_r_a_t_i_o_n_s. Declaration is special markup that begins with <>, such as <>, that may contain comments between a pair of ---- delimiters. HTML comments are ‘‘empty decla- rations’’, SGML declarations without any non-comment text. There- fore, <> is a valid comment, and so is <>, but <> is not. On the other hand, most HTML writers don’t perceive comments as anything other than text delimited with <>, which is not quite the same. For example, something like <> works as a valid comment as long as the number of dashes is a multiple of four (!). If not, the comment technically lasts until the next ----, which may be at the other end of the document. Because of this, many popular browsers completely ignore the specification and implement what users have come to expect: comments delimited with <>. Until version 1.9, Wget interpreted comments strictly, which resulted in missing links in many web pages that displayed fine in browsers, but had the misfortune of containing non-compliant com- ments. Beginning with version 1.9, Wget has joined the ranks of clients that implements ‘‘naive’’ comments, terminating each com- ment at the first occurrence of ---->>. If, for whatever reason, you want strict comment parsing, use this option to turn it on. RReeccuurrssiivvee AAcccceepptt//RReejjeecctt OOppttiioonnss --AA _a_c_c_l_i_s_t ----aacccceepptt _a_c_c_l_i_s_t --RR _r_e_j_l_i_s_t ----rreejjeecctt _r_e_j_l_i_s_t Specify comma-separated lists of file name suffixes or patterns to accept or reject.. --DD _d_o_m_a_i_n_-_l_i_s_t ----ddoommaaiinnss==_d_o_m_a_i_n_-_l_i_s_t Set domains to be followed. _d_o_m_a_i_n_-_l_i_s_t is a comma-separated list of domains. Note that it does _n_o_t turn on --HH. ----eexxcclluuddee--ddoommaaiinnss _d_o_m_a_i_n_-_l_i_s_t Specify the domains that are _n_o_t to be followed.. ----ffoollllooww--ffttpp Follow FTP links from HTML documents. Without this option, Wget will ignore all the FTP links. ----ffoollllooww--ttaaggss==_l_i_s_t Wget has an internal table of HTML tag / attribute pairs that it considers when looking for linked documents during a recursive retrieval. If a user wants only a subset of those tags to be con- sidered, however, he or she should be specify such tags in a comma-separated _l_i_s_t with this option. ----iiggnnoorree--ttaaggss==_l_i_s_t This is the opposite of the ----ffoollllooww--ttaaggss option. To skip certain HTML tags when recursively looking for documents to download, specify them in a comma-separated _l_i_s_t. In the past, this option was the best bet for downloading a single page and its requisites, using a command-line like: wget --ignore-tags=a,area -H -k -K -r http:/// However, the author of this option came across a page with tags like "" and came to the realization that specifying tags to ignore was not enough. One can’t just tell Wget to ignore "", because then stylesheets will not be downloaded. Now the best bet for downloading a single page and its requisites is the dedicated ----ppaaggee--rreeqquuiissiitteess option. --HH ----ssppaann--hhoossttss Enable spanning across hosts when doing recursive retrieving. --LL ----rreellaattiivvee Follow relative links only. Useful for retrieving a specific home page without any distractions, not even those from the same hosts. --II _l_i_s_t ----iinncclluuddee--ddiirreeccttoorriieess==_l_i_s_t Specify a comma-separated list of directories you wish to follow when downloading. Elements of _l_i_s_t may contain wildcards. --XX _l_i_s_t ----eexxcclluuddee--ddiirreeccttoorriieess==_l_i_s_t Specify a comma-separated list of directories you wish to exclude from download. Elements of _l_i_s_t may contain wildcards. --nnpp ----nnoo--ppaarreenntt Do not ever ascend to the parent directory when retrieving recur- sively. This is a useful option, since it guarantees that only the files _b_e_l_o_w a certain hierarchy will be downloaded. EEXXAAMMPPLLEESS The examples are divided into three sections loosely based on their complexity. SSiimmppllee UUssaaggee · Say you want to download a URL. Just type: wget http://fly.srk.fer.hr/ · But what will happen if the connection is slow, and the file is lengthy? The connection will probably fail before the whole file is retrieved, more than once. In this case, Wget will try getting the file until it either gets the whole of it, or exceeds the default number of retries (this being 20). It is easy to change the number of tries to 45, to insure that the whole file will arrive safely: wget --tries=45 http://fly.srk.fer.hr/jpg/flyweb.jpg · Now let’s leave Wget to work in the background, and write its progress to log file _l_o_g. It is tiring to type ----ttrriieess, so we shall use --tt. wget -t 45 -o log http://fly.srk.fer.hr/jpg/flyweb.jpg & The ampersand at the end of the line makes sure that Wget works in the background. To unlimit the number of retries, use --tt iinnff. · The usage of FTP is as simple. Wget will take care of login and password. wget ftp://gnjilux.srk.fer.hr/welcome.msg · If you specify a directory, Wget will retrieve the directory list- ing, parse it and convert it to HTML. Try: wget ftp://ftp.gnu.org/pub/gnu/ links index.html AAddvvaanncceedd UUssaaggee · You have a file that contains the URLs you want to download? Use the --ii switch: wget -i If you specify -- as file name, the URLs will be read from standard input. · Create a five levels deep mirror image of the GNU web site, with the same directory structure the original has, with only one try per document, saving the log of the activities to _g_n_u_l_o_g: wget -r http://www.gnu.org/ -o gnulog · The same as the above, but convert the links in the HTML files to point to local files, so you can view the documents off-line: wget --convert-links -r http://www.gnu.org/ -o gnulog · Retrieve only one HTML page, but make sure that all the elements needed for the page to be displayed, such as inline images and external style sheets, are also downloaded. Also make sure the downloaded page references the downloaded links. wget -p --convert-links http://www.server.com/dir/page.html The HTML page will be saved to _w_w_w_._s_e_r_v_e_r_._c_o_m_/_d_i_r_/_p_a_g_e_._h_t_m_l, and the images, stylesheets, etc., somewhere under _w_w_w_._s_e_r_v_e_r_._c_o_m_/, depending on where they were on the remote server. · The same as the above, but without the _w_w_w_._s_e_r_v_e_r_._c_o_m_/ directory. In fact, I don’t want to have all those random server directories anyway---just save _a_l_l those files under a _d_o_w_n_l_o_a_d_/ subdirectory of the current directory. wget -p --convert-links -nH -nd -Pdownload \ http://www.server.com/dir/page.html · Retrieve the index.html of wwwwww..llyyccooss..ccoomm, showing the original server headers: wget -S http://www.lycos.com/ · Save the server headers with the file, perhaps for post-process- ing. wget --save-headers http://www.lycos.com/ more index.html · Retrieve the first two levels of wwuuaarrcchhiivvee..wwuussttll..eedduu, saving them to _/_t_m_p. wget -r -l2 -P/tmp ftp://wuarchive.wustl.edu/ · You want to download all the GIFs from a directory on an HTTP server. You tried wwggeett hhttttpp::////wwwwww..sseerrvveerr..ccoomm//ddiirr//**..ggiiff, but that didn’t work because HTTP retrieval does not support globbing. In that case, use: wget -r -l1 --no-parent -A.gif http://www.server.com/dir/ More verbose, but the effect is the same. --rr --ll11 means to retrieve recursively, with maximum depth of 1. ----nnoo--ppaarreenntt means that references to the parent directory are ignored, and --AA..ggiiff means to download only the GIF files. --AA ""**..ggiiff"" would have worked too. · Suppose you were in the middle of downloading, when Wget was interrupted. Now you do not want to clobber the files already present. It would be: wget -nc -r http://www.gnu.org/ · If you want to encode your own username and password to HTTP or FTP, use the appropriate URL syntax. wget ftp://hniksic:mypassword@unix.server.com/.emacs Note, however, that this usage is not advisable on multi-user sys- tems because it reveals your password to anyone who looks at the output of "ps". · You would like the output documents to go to standard output instead of to files? wget -O - http://jagor.srce.hr/ http://www.srce.hr/ You can also combine the two options and make pipelines to retrieve the documents from remote hotlists: wget -O - http://cool.list.com/ │ wget --force-html -i - VVeerryy AAddvvaanncceedd UUssaaggee · If you wish Wget to keep a mirror of a page (or FTP subdirecto- ries), use ----mmiirrrroorr (--mm), which is the shorthand for --rr --ll iinnff --NN. You can put Wget in the crontab file asking it to recheck a site each Sunday: crontab 0 0 * * 0 wget --mirror http://www.gnu.org/ -o /home/me/weeklog · In addition to the above, you want the links to be converted for local viewing. But, after having read this manual, you know that link conversion doesn’t play well with timestamping, so you also want Wget to back up the original HTML files before the conver- sion. Wget invocation would look like this: wget --mirror --convert-links --backup-converted \ http://www.gnu.org/ -o /home/me/weeklog · But you’ve also noticed that local viewing doesn’t work all that well when HTML files are saved under extensions other than ..hhttmmll, perhaps because they were served as _i_n_d_e_x_._c_g_i. So you’d like Wget to rename all the files served with content-type tteexxtt//hhttmmll or aapppplliiccaattiioonn//xxhhttmmll++xxmmll to _n_a_m_e_._h_t_m_l. wget --mirror --convert-links --backup-converted \ --html-extension -o /home/me/weeklog \ http://www.gnu.org/ Or, with less typing: wget -m -k -K -E http://www.gnu.org/ -o /home/me/weeklog FFIILLEESS //eettcc//wwggeettrrcc Default location of the _g_l_o_b_a_l startup file. ..wwggeettrrcc User startup file. BBUUGGSS You are welcome to send bug reports about GNU Wget to . Before actually submitting a bug report, please try to follow a few simple guidelines. 1. Please try to ascertain that the behavior you see really is a bug. If Wget crashes, it’s a bug. If Wget does not behave as docu- mented, it’s a bug. If things work strange, but you are not sure about the way they are supposed to work, it might well be a bug. 2. Try to repeat the bug in as simple circumstances as possible. E.g. if Wget crashes while downloading wwggeett --rrll00 --kkKKEE --tt55 --YY00 hhttttpp::////yyooyyooddyynnee..ccoomm --oo //ttmmpp//lloogg, you should try to see if the crash is repeatable, and if will occur with a simpler set of options. You might even try to start the download at the page where the crash occurred to see if that page somehow triggered the crash. Also, while I will probably be interested to know the contents of your _._w_g_e_t_r_c file, just dumping it into the debug message is prob- ably a bad idea. Instead, you should first try to see if the bug repeats with _._w_g_e_t_r_c moved out of the way. Only if it turns out that _._w_g_e_t_r_c settings affect the bug, mail me the relevant parts of the file. 3. Please start Wget with --dd option and send us the resulting output (or relevant parts thereof). If Wget was compiled without debug support, recompile it---it is _m_u_c_h easier to trace bugs with debug support on. Note: please make sure to remove any potentially sensitive infor- mation from the debug log before sending it to the bug address. The "-d" won’t go out of its way to collect sensitive information, but the log _w_i_l_l contain a fairly complete transcript of Wget’s communication with the server, which may include passwords and pieces of downloaded data. Since the bug address is publically archived, you may assume that all bug reports are visible to the public. 4. If Wget has crashed, try to run it in a debugger, e.g. "gdb ‘which wget‘ core" and type "where" to get the backtrace. This may not work if the system administrator has disabled core files, but it is safe to try. SSEEEE AALLSSOO GNU Info entry for _w_g_e_t. AAUUTTHHOORR Originally written by Hrvoje Niksic . CCOOPPYYRRIIGGHHTT Copyright (c) 1996--2005 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being ‘‘GNU General Public License’’ and ‘‘GNU Free Documentation License’’, with no Front-Cover Texts, and with no Back- Cover Texts. A copy of the license is included in the section enti- tled ‘‘GNU Free Documentation License’’. GNU Wget 1.10.2 (Red Hat modified)2005-11-02 WGET(1)