WGET(1) | GNU Wget | WGET(1) |
wget - neinteraktivní nástroj k stahování souborů
wget [volba]... [URL]...
GNU Wget je nástroj pro neinteraktivní stahování souborů z WWW. Podporuje protokoly HTTP, HTTPS, a FTP, i stahování přes HTTP proxy.
Wget je neinteraktivní program, což znamená, že dovede pracovat na pozadí, i když není uživatel přihlášen. Lze tedy spustit program, odhlásit se a počkat, až dodělá určenou práci. Naopak většina www prohlížečů vyžaduje neustálou přítomnost uživatele, což může být v případě přenosu většího množství dat na obtíž.
Wget can follow links in HTML, XHTML, and CSS pages, to create local versions of remote web sites, fully recreating the directory structure of the original site. This is sometimes referred to as "recursive downloading." While doing that, Wget respects the Robot Exclusion Standard (/robots.txt). Wget can be instructed to convert the links in downloaded files to point at the local files, for offline viewing.
Wget byl navržen pro robustnost na pomalých nebo nestabilních sítových připojeních; pokud stahování selže kvůli problému v síti, bude to zkoušet znovu, dokud jej nestáhne celý. Pokud server podporuje obnovení stahování (regetting), požádá jej o obnovení stahování v místě, kde předtím skončil.
Protože Wget používá ke zpracování argumentů příkazové řádky GNU getopt, má každá volba dlouhou a krátkou formu. Dlouhé se lépe pamatují, ale zdržují při psaní. Je možné obě formy libovolně kombinovat nebo uvádět volby za argumenty příkazové řádky. Tak je možné napsat:
wget -r --tries=10 http://fly.srk.fer.hr/ -o log
Mezeru mezi volbou, která akceptuje argument, a argumentem lze vypustit. Namísto -o log lze napsat -olog.
Volby, které argument nevyžadují, je možné sloučit, jako:
wget -drc <URL>
To je rovnocenné zápisu:
wget -d -r -c <URL>
Protože volby je možné uvést za argumenty, můžete argumenty ukončit s --. Tj. následující zápis se pokusí stáhnout URL -x, selhání zapíše do log:
wget -o log -- -x
Volby, které akceptují seznamy oddělené čárkou respektují konvenci, že určení prázdného seznamu vymaže jeho hodnotu. To lze využít pro zrušení nastavení z .wgetrc. Například pokud .wgetrc nastavuje "exclude_directories" na /cgi-bin, následující příklad je nejprve vymaže a potom nastaví na vyloučení /~nobody a /~somebody. Seznamy je také možno vymazat ve .wgetrc.
wget -X "" -X /~nobody,/~somebody
Většina voleb, které neakceptují argumenty, jsou booleovské volby, protože jejich stav lze zachytit jako ano nebo ne ("booleovskou proměnnou"). Například --follow-ftp nastaví Wget, aby následoval FTP odkazy z HTML souborů a na druhou stranu --no-glob mu přikazuje neprovádět globbing souborů na FTP URLs. Booleovská volba je buďto kladná nebo záporná (začínající na --no). Všechny takové volby mají některé vlastnosti společné.
Pokud není řečeno jinak, předpokládá se, že výchozí chování je opačné k uvedené volbě. Například z toho, že existuje volba --follow-ftp, vyplývá, že výchozím chováním je nenásledovat FTP odkazy z HTML stránek.
Affirmative options can be negated by prepending the --no- to the option name; negative options can be negated by omitting the --no- prefix. This might seem superfluous---if the default for an affirmative option is to not do something, then why provide a way to explicitly turn it off? But the startup file may in fact change the default. For instance, using "follow_ftp = on" in .wgetrc makes Wget follow FTP links by default, and using --no-follow-ftp is the only way to restore the factory default from the command line.
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. If --force-html is not specified, then file should consist of a series of URLs, one per line.
Nicméně, když určíte --force-html, na dokument se bude pohlížet jako na HTML. V tomto případě můžou nastat problémy s relativními odkazy, což lze vyřešit buď přidáním "<base href="url">" do dokumentu nebo blíže určit --base=url v příkazové řádce.
If the file is an external one, the document will be automatically treated as html if the Content-Type matches text/html. Furthermore, the file's location will be implicitly used as base href if none was specified.
Be aware that the URL might contain private information like access tokens or credentials.
For instance, if you specify http://foo/bar/a.html for URL, and Wget reads ../baz/b.html from the input file, it would be resolved to http://foo/baz/b.html.
Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there.
For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it will always have a very new timestamp. A warning will be issued if this combination is used.
Similarly, using -r or -p with -O may not work as you expect: Wget won't just download the first file to file and then download the rest to their normal names: all downloaded content will be placed in file. This was disabled in version 1.11, but has been reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.
A combination with -nc is only accepted if the given output file does not exist.
Note that a combination with -k is only permitted when downloading a single document, as in that case it will just convert all relative URIs to external ones; -k makes no sense for multiple URIs when they're all being downloaded to a single file; -k can be used only when the output is a regular file.
When running Wget without -N, -nc, -r, or -p, downloading the same file in the same directory will result in the original copy of file being preserved and the second copy being named file.1. If that file is downloaded yet again, the third copy will be named file.2, and so on. (This is also the behavior with -nd, even if -r or -p are in effect.) When -nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file. Therefore, ""no-clobber"" is actually a misnomer in this mode---it's not clobbering that's prevented (as the numeric suffixes were already preventing clobbering), but rather the multiple version saving that's prevented.
When running Wget with -r or -p, but without -N, -nd, or -nc, re-downloading a file will result in the new copy simply overwriting the old. Adding -nc will prevent this behavior, instead causing the original version to be preserved and any newer copies on the server to be ignored.
When running Wget with -N, with or without -r or -p, 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. -nc may not be specified at the same time as -N.
A combination with -O/--output-document is only accepted if the given output file does not exist.
Pozor, pokud je použita volba -nc, budou soubory s příponou .html nebo .htm nahrány z lokálního disku a zpracovány jako by byly staženy z webu.
wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z
Pokud je v aktuálním adresáři soubor s názvem ls-lR.Z, Wget bude předpokládat, že se jedná o první část vzdáleného souboru a požádá server o pokračování v přenosu od offsetu rovnému délce lokálního souboru.
Všimněte si, že tento parametr není nutné zadávat, pokud pouze chcete, aby Wget pokračoval ve stahování souboru po přerušení spojení. To je jeho výchozí chování. -c má vliv pouze na obnovení stahování započatých před spuštěním aktuální instance Wgetu, a pokud stále ještě jsou k dispozici lokální soubory.
Bez volby -c by předchozí příklad pouze stáhnul vzdálený soubor jako ls-lR.Z.1 a zkrácený soubor ls-lR.Z by nechal být.
If you use -c on a non-empty file, and the server does not support continued downloading, Wget will restart the download from scratch and overwrite the existing file entirely.
Beginning with Wget 1.7, if you use -c 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.
Na druhou stranu při použití -c je jakýkoliv soubor, který je na serveru větší než soubor lokální, považován za nedokončené stahování a bude staženo a připojeno na konec lokálního souboru pouze "(délka(vzdálený) - délka(lokální))" bajtů. To se může někdy hodit---například při použití wget -c ke stažení pouze nové části připojené k souboru dat nebo logu.
Nicméně pokud je soubor na serveru větší, protože byl změněn, na rozdíl od pouhého připojení, vznikne pokažený soubor. Wget nemá žádnou možnost ověřit, že lokální soubor je skutečně platnou částí vzdáleného souboru. Zvláštní pozornost je potřeba při použití -c spolu s -r, protože každý soubor bude považován za potenciální "nedokončené stahování".
Dalším případem, kdy dojde s volbou -c k poškození souboru je hloupá HTTP proxy vkládající do lokálního souboru řetězec "transfer interrupted". V budoucnu může být pro tyto případy přidána volba "rollback".
Pozor, -c funguje pouze s FTP servery a s HTTP servery, které podporují hlavičku "Range".
--start-pos has higher precedence over --continue. When --start-pos and --continue are both specified, wget will emit a warning then proceed as if --continue was absent.
Server support for continued download is required, otherwise --start-pos cannot help. See -c for details.
Jako výchozí je nastaven "bar" (čárový). Vykresluje ASCII čáru postupu (alias "teploměr"), který ukazuje stav stahování.Pokud výstup není TTY, je jako výchozí použit "dot" (tečkový).
Pro přepnutí na "dot" použijte --progress=dot. Při stahování vypisuje na obrazovku tečky; každá tečka reprezentuje fixní objem stažených dat.
The progress type can also take one or more parameters. The parameters vary based on the type selected. Parameters to type are passed by appending them to the type sperated by a colon (:) like this: --progress=type:parameter1:parameter2.
When using the dotted retrieval, you may set the style by specifying the type as dot:style. Different styles assign different meaning to one dot. With the "default" style each dot represents 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 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). If "mega" is not enough then you can use the "giga" style---each dot represents 1M retrieved, there are eight dots in a cluster, and 32 dots on each line (so each line contains 32M).
With --progress=bar, there are currently two possible parameters, force and noscroll.
When the output is not a TTY, the progress bar always falls back to "dot", even if --progress=bar was passed to Wget during invocation. This behaviour can be overridden and the "bar" output forced by using the "force" parameter as --progress=bar:force.
By default, the bar style progress bar scroll the name of the file from left to right for the file being downloaded if the filename exceeds the maximum length allotted for its display. In certain cases, such as with --progress=bar:force, one may not want the scrolling filename in the progress bar. By passing the "noscroll" parameter, Wget can be forced to display as much of the filename as possible without scrolling through it.
Note that you can set the default style using the "progress" command in .wgetrc. That setting may be overridden from the command line. For example, to force the bar output without scrolling, use --progress=bar:force:noscroll.
By default, wget only displays the progress bar in verbose mode. One may however, want wget to display the progress bar on screen in conjunction with any other verbosity modes like --no-verbose or --quiet. This is often a desired a property when invoking wget to download several small/large files. In such a case, wget could simply be invoked with this parameter to get a much cleaner output on the screen.
This option will also force the progress bar to be printed to stderr when used alongside the --output-file option.
By default, when a file is downloaded, its timestamps are set to match those from the remote file. This allows the use of --timestamping on subsequent invocations of wget. However, it is sometimes useful to base the local file's timestamp on when it was actually downloaded; for that purpose, the --no-use-server-timestamps option has been provided.
wget --spider --force-html -i bookmarks.html
Na této funkcionalitě se ještě musí zapracovat, aby se alespoň přiblížila skutečným web spiders.
Kdykoliv probíhá síťová operace, Wget může ověřovat prodlevu a operaci přerušit, pokud trvá příliš dlouho. Tak lze zabránit zamrznutí nebo nekonečným spojením. Jediným časovým limitem, který je jako výchozí nastaven, je 900 vteřin na čtení. Nastavením na 0 se vyřadí. Výchozí hodnotu je záhodno měnit pouze v případě, že skutečně víte, co děláte.
Všechny volby týkající se časových limitů akceptují hodnoty v desítkové soustavě, včetně hodnot pod vteřinu. Např. 0.1 vteřin je platnou (ačkoliv nevhodnou) hodnotou. Hodnoty pod vteřinu se hodí při testování časů odpovědi serveru nebo latence sítě.
Samozřejmě vzdálený server se může rozhodnout ukončit spojení dříve než stanoví tato volba. Výchozí hodnotou časového limitu pro čtení je 900 vteřin.
Tato volba umožňuje použít desetiny, obvykle spolu s příponami; např. --limit-rate=2.5k je platné nastavení.
Všimněte si, že Wget implementuje omezování nečinností po určitý čas, v případě, že čtení ze sítě trvalo méně nežli je určeno limitem. Tato strategie způsobí, že TCP přenos se zpomalí zhruba na rychlost danou limitem. Nicméně dosažení rovnováhy může chvíli trvat, takže v případě velmi malých souborů to moc dobře nefunguje.
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. The waiting interval specified by this function is influenced by "--random-wait", which see.
By default, Wget will assume a value of 10 seconds.
A 2001 article in a publication devoted to development on a popular 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 --random-wait option was inspired by this ill-advised recommendation to block many unrelated users from a web site due to the actions of one.
Note that quota will never affect downloading a single file. So if you specify wget -Q10k https://example.com/ls-lR.gz, all of the ls-lR.gz will be downloaded. The same goes even when several URLs are specified on the command-line. The quota is checked only at the end of each downloaded file, so it will never result in a partially downloaded file. Thus you may safely type wget -Q2m -i sites---download will be aborted after the file that exhausts the quota is completely downloaded.
Zadáním kvóty na 0 nebo inf se kvóta nastaví na nekonečno.
Nicméně jsou případy, kdy není žádoucí udržovat jména hostitelů ve vyrovnávací paměti, a to ani po krátkou dobu. S touto volbou Wget pro každé nové spojení použije nový DNS dotaz (přesněji nové volání "gethostbyname" nebo "getaddrinfo"). Tato volba neovlivní cachování, které může provádět DNS knihovna nebo externí vyrovnávací vrstva, jako je třeba NSCD.
Pokud přesně nerozumíte, k čemu tato volba slouží, pravděpodobně ji nepotřebujete.
By default, Wget escapes the characters that are not valid or safe as part of file names on your operating system, as well as control characters that are typically unprintable. This option is useful for changing these defaults, perhaps because you are downloading to a non-native partition, or because you want to disable escaping of the control characters, or you want to further restrict characters to only those in the ASCII range of values.
The modes are a comma-separated set of text values. The acceptable values are unix, windows, nocontrol, ascii, lowercase, and uppercase. The values unix and windows are mutually exclusive (one will override the other), as are lowercase and uppercase. Those last are special cases, as they do not change the set of characters that would be escaped, but rather force local file paths to be converted either to lower- or uppercase.
When "unix" is specified, Wget escapes the character / and the control characters in the ranges 0--31 and 128--159. This is the default on Unix-like operating systems.
When "windows" is given, 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 www.xemacs.org:4300/search.pl?input=blah in Unix mode would be saved as www.xemacs.org+4300/search.pl@input=blah in Windows mode. This mode is the default on Windows.
If you specify nocontrol, then the escaping of the control characters is also switched off. This option may make sense when you are downloading URLs whose names contain UTF-8 characters, on a system which can save and display filenames in UTF-8 (some possible byte values used in UTF-8 byte sequences fall in the range of values designated by Wget as "controls").
The ascii mode is used to specify that any bytes whose values are outside the range of ASCII characters (that is, greater than 127) shall be escaped. This can be useful when saving filenames whose encoding does not match the one used locally.
Žádnou z těchto voleb by nemělo být nutné nastavovat ručně. Jako výchozí Wget, který IPv6 umí, použije druh adres, určený DNS záznamem hostitele. Pokud DNS odpoví IPv4 i IPv6 adresou, Wget je postupně zkusí, dokud nenajde tu, ke které se dá připojit. (Také viz volba "--prefer-family" popsaná níže.)
Tyto volby mohou být použity k vynucení užití IPv4 nebo IPv6 adres na systémech, které podporují obě možnosti, obvykle za účelem ladění nebo řešení rozbité konfigurace sítě. Najednou může být použita pouze jedna z voleb --inet6-only a --inet4-only. Pokud nebyl Wget zkompilován s podporou IPv6, nejsou tyto volby dostupné.
Tím se vyhne falešným chybám a pokusům o spojení, při přístupu z IPv4 sítí k hostitelům, kteří mají jak IPv6 tak IPv4 záznam. Například www.kame.net se překládá na 2001:200:0:8002:203:47ff:fea5:3085 a na 203.178.141.194. Je-li preferováno "IPv4", poižije se IPv4 adresa jako první; je-li preferováno "IPv6", použije se jako první IPv6 adresa; je-li zadána hodnota "none", je pořadí adres vrácených DNS použito beze změny.
Na rozdíl od -4 a -6 tato volba neomezuje používání na jediný druh adres, pouze mění pořadí, ve kterém je k adresám přistupováno. Také si všimněte, že provedená změna pořadí je stabilní---neovlivnuje pořadí adres stejného druhu, tj. relativní pořadí všech IPv4 adres a všech IPv6 adres zůstává ve všech případech nedotčeno.
You can set the default command for use-askpass in the .wgetrc. That setting may be overridden from the command line.
You can set the default state of IRI support using the "iri" command in .wgetrc. That setting may be overridden from the command line.
Wget use the function "nl_langinfo()" and then the "CHARSET" environment variable to get the locale. If it fails, ASCII is used.
You can set the default local encoding using the "local_encoding" command in .wgetrc. That setting may be overridden from the command line.
For HTTP, remote encoding can be found in HTTP "Content-Type" header and in HTML "Content-Type http-equiv" meta tag.
You can set the default encoding using the "remoteencoding" command in .wgetrc. That setting may be overridden from the command line.
Viz např. adresář ftp://ftp.xemacs.org/pub/xemacs/. Při jeho stažení s -r bude uložen lokálně v ftp.xemacs.org/pub/xemacs/. Zatímco volba -nH může odstranit podadresář ftp.xemacs.org/, ale pořád zbývá pub/xemacs. Tady se --cut-dirs hodí; způsobí, že Wget nebude "see" počet podadresářů vzdáleného adresáře. Následuje několik příkladů fungování volby --cut-dirs.
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/ ...
Pokud je pouze potřeba zbavit se adresářové struktury, lze podobného výsledku dosáhnout kombinací -nd a -P. Nicméně narozdíl od -nd volba --cut-dirs neruší podadresáře---např. při použití -nH --cut-dirs=1 bude podadresář beta/ podle očekávání umístěn do xemacs/beta.
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.html file corresponds to remote URL X (since it doesn't yet know that the URL produces output of type text/html or application/xhtml+xml.
As of version 1.12, Wget will also ensure that any downloaded files of type text/css end in the suffix .css, and the option was renamed from --html-extension, to better reflect its new behavior. The old option name is still acceptable, but should now be considered deprecated.
As of version 1.19.2, Wget will also ensure that any downloaded files with a "Content-Encoding" of br, compress, deflate or gzip end in the suffix .br, .Z, .zlib and .gz respectively.
At some point in the future, this option may well be expanded to include suffixes for other types of content, including content types that are not parsed by Wget.
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, use the --use-askpass or store them in .wgetrc or .netrc, 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.
Tato volba se hodí v případě, kdy z nějakého důvodu, trvalá (keep-alive) spojení nefungují, např. díky chybě v serveru nebo neschopnosti skriptů na straně serveru vypořádat se se spojeními.
Používání vyrovnávací paměti je ve výchozím stavu povoleno.
Tato volba je typicky používána v případech zrcadlení serverů, které vyžadují přihlášení pro přístup k části nebo celému obsahu. Přihlašovací proces obvykle probíhá tak, že web server na základě přijatých a ověřených přihlašovacích informací vydá HTTP cookie. Tuto cookie potom prohlížeč při přístupu do vyhrazené části posílá serveru, čímž prokazuje svou identitu.
Zrcadlení takového serveru vyžaduje, aby Wget posílal stejné cookies, jako posílá váš prohlížeč. Toho se dosáhne volbou --load-cookies---prostě se Wgetu předá umístění souboru cookies.txt a bude posílat stejné cookies, jako by v dané situaci posílal váš prohlížeč. Různé prohlížeče udržují textové cookie soubory na různých místech:
Pokud není možné použít --load-cookies, je tu ještě jedna alternativa. Pokud prohlížeč podporuje "správu cookie", je možné použít jej pro zobrazení cookies, které jsou používány k přístupu k zrcadlenému serveru. Opište si název a hodnotu cookie a ručně nařiďte Wgetu, aby je posílal, čímž "oficiální" podporu cookies obejdete:
wget --no-cookies --header "Cookie: <název>=<hodnota>"
Protože formát cookie souboru normálně neobsahuje session cookies, Wget je označí časem expirace 0. Volba --load-cookies je rozpozná jako session cookies, ale ostatní prohlížeče to může zmást. Také si všimněte, že s takto nahranými cookies bude zacházeno jako s ostatními session cookies, tj. pokud je má volba --save-cookies opět zachovat, je nutné znovu použít --keep-session-cookies.
S touto volbou bude Wget hlavičku "Content-Length" ignorovat--- jako by nikdy neexistovala.
Pro definování více hlaviček je možné použít --header vícenásobně.
wget --header='Accept-Charset: iso-8859-2' \ --header='Accept-Language: hr' \ http://fly.srk.fer.hr/
Nastavením hodnoty na prázdný řetězec se smažou všechny dříve definované hlavičky.
Od verze 1.10 může být tato volba použita pro přepsání jinak automaticky generovaných hlaviček. Následující příkaz instruuje Wget, aby se připojil na localhost, ale použil foo.bar v hlavičce "Host":
wget --header="Host: foo.bar" http://localhost/
Ve verzích před 1.10 takové použití volby --header způsobovalo posílání duplicitních hlaviček.
If auto or gzip are specified, Wget asks the server to compress the file using the gzip compression format. If the server compresses the file and responds with the "Content-Encoding" header field set appropriately, the file will be decompressed automatically.
If none is specified, wget will not ask the server to compress the file and will not decompress any server responses. This is the default.
Compression support is currently experimental. In case it is turned on, please report any bugs to "bug-wget@gnu.org".
I zde platí bezpečnostní ohledy popsané u --http-password.
HTTP protokol umožňuje klientům identifikovat se pomocí hlavičky "User-Agent". Tak je možné odlišit WWW software, obvykle pro statistické účely nebo pro sledování porušování protokolu. Wget se normálně identifikuje jako Wget/verze, kde verze je aktuální číslo verze Wgetu.
Nicméně některé servery uplatňují politiku výstupu na míru podle informací z "User-Agent". Zatímco teoreticky to není tak špatný nápad, bývá to zneužíváno servery k odepření informací klientům jiným než (historicky) Netscape nebo častěji Microsoft Internet Explorer. Tato volba umožňuje změnit řádek "User-Agent" posílaný Wgetem. Pokud nevíte, co děláte, nepoužívejte tuto volbu.
Určením prázdného řetězce pomocí --user-agent="" způsobí, že Wget hlavičku "User-Agent" v HTTP požadavcích nepošle vůbec.
Please note that wget does not require the content to be of the form "key1=value1&key2=value2", and neither does it test for it. Wget will simply transmit whatever data is provided to it. Most servers however expect the POST data to be in the above format when processing HTML Forms.
When sending a POST request using the --post-file option, Wget treats the file as a binary file and will send every character in the POST request without stripping trailing newline or formfeed characters. Any other control characters in the text will also be sent as-is in the POST request.
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 /dev/stdin won't work. It's not quite clear how to work around this limitation inherent in HTTP/1.0. Although HTTP/1.1 introduces chunked transfer 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 completed -- a chicken-and-egg problem.
Note: As of version 1.15 if Wget is redirected after the POST request is completed, its behaviour will depend on the response code returned by the server. In case of a 301 Moved Permanently, 302 Moved Temporarily or 307 Temporary Redirect, Wget will, in accordance with RFC2616, continue to send a POST request. In case a server wants the client to change the Request method upon redirection, it should send a 303 See Other response code.
Následující příklad ukazuje, jak se přihlásit na server pomocí POST a poté přistoupit ke stažení požadovaných stránek, které jsou přístupné pouze autorizovaným uživatelům:
# Log in to the server. This can be done only once. wget --save-cookies cookies.txt \ --post-data 'user=foo&password=bar' \ http://example.com/auth.php # Now grab the page or pages we care about. wget --load-cookies cookies.txt \ -p http://example.com/interesting/article.php
Pokud server používá ke sledování autentizace uživatelů session cookies, nebude tento příklad fungovat, protože --save-cookies je neuloží (ani prohlížeče je neuloží) a soubor cookies.txt bude prázdný V tom případě pro vynucené ukládání session cookies přidejte volbu --keep-session-cookies.
Currently, --body-file is not for transmitting files as a whole. Wget does not currently support "multipart/form-data" for transmitting data; only "application/x-www-form-urlencoded". In the future, this may be changed so that wget sends the --body-file as a complete file instead of sending its contents to the server. Please be aware that Wget needs to know the contents of BODY Data in advance, and hence the argument to --body-file should be a regular file. See --post-file for a more detailed explanation. Only one of --body-data and --body-file should be specified.
If Wget is redirected after the request is completed, Wget will suspend the current method and send a GET request till the redirection is completed. This is true for all redirection response codes except 307 Temporary Redirect which is used to explicitly specify that the request method should not change. Another exception is when the method is set to "POST", in which case the redirection rules specified under --post-data are followed.
This option is useful for some file-downloading CGI programs that use "Content-Disposition" headers to describe what the name of a downloaded file should be.
When combined with --metalink-over-http and --trust-server-names, a Content-Type: application/metalink4+xml file is named using the "Content-Disposition" filename field, if available.
Use of this option is not recommended, and is intended only to support some few obscure servers, which never send HTTP authentication challenges, but accept unsolicited auth info, say, in addition to form-based authentication.
Using this option is intended to support special use cases only and is generally not recommended, as it can force retries even in cases where the server is actually trying to decrease its load. Please use wisely and only if you know what you are doing.
To support encrypted HTTP (HTTPS) downloads, Wget must be compiled with an external SSL library. The current default is GnuTLS. In addition, Wget also supports HSTS (HTTP Strict Transport Security). If Wget is compiled without SSL support, none of these options are available.
Specifying SSLv2, SSLv3, TLSv1, TLSv1_1, TLSv1_2 or TLSv1_3 forces the use of the corresponding protocol. This is useful when talking to old and buggy SSL server implementations that make it hard for the underlying SSL library to choose the correct protocol version. Fortunately, such servers are quite rare.
Specifying PFS enforces the use of the so-called Perfect Forward Security cipher suites. In short, PFS adds security by creating a one-time key for each SSL connection. It has a bit more CPU impact on client and server. We use known to be secure ciphers (e.g. no MD4) and the TLS protocol. This mode also explicitly excludes non-PFS key exchange methods, such as RSA.
Od verze 1.10 je jako výchozí nastaveno ověřování certifikátu serveru u známých certifikačních autorit s přerušením SSL handshake a zrušením stahování, pokud ověření selže. Ačkoliv je tak dosaženo bezpečnějšího stahování, spolupráce s některými servery, které s předchozími verzemi fungovaly, nebude fungovat, zvláště pokud používají certifikáty podepsané sebou samými, prošlé nebo jinak neplatné. Tato volba vynutí "nezabezpečený režim, který změní chyby ověření certifikátu na varování a umožní pokračovat.
If you encounter "certificate verification" errors or ones saying that "common name doesn't match requested host name", you can use this option to bypass the verification and proceed with the download. Only use this option if you are otherwise convinced of the site's authenticity, or if you really don't care about the validity of its certificate. It is almost always a bad idea not to check the certificates when transmitting confidential or important data. For self-signed/internal certificates, you should download the certificate and verify against that instead of forcing this insecure mode. If you are really sure of not desiring any certificate verification, you can specify --check-certificate=quiet to tell wget to not print any warning about invalid certificates, albeit in most cases this is the wrong thing to do.
Bez této volby Wget hledá certifikáty CA na místech určených systémem, vybraných při instalaci OpenSSH.
Bez této volby Wget hledá certifikáty CA na místech určených systémem, vybraných při instalaci OpenSSH.
When negotiating a TLS or SSL connection, the server sends a certificate indicating its identity. A public key is extracted from this certificate and if it does not exactly match the public key(s) provided to this option, wget will abort the connection before sending or receiving any data.
On such systems the SSL library needs an external source of randomness to initialize. Randomness may be provided by EGD (see --egd-file 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 $HOME/.rnd.
Pokud se objevuje chyba "Could not seed OpenSSL PRNG; disabling SSL.", je třeba dodat náhodná data jednou z popsaných metod.
OpenSSL umožňuje uživateli zvolit vlastní zdroj entropie pomocí proměnné prostředí "RAND_FILE". Pokud není tato proměnná nastavena nebo pokud určený soubor neposkytuje dostatek náhodnosti, OpenSSL bude číst náhodná data z EGD soketu určeného touto volbou.
Pokud není tato volba určena (a není použit ekvivalentní příkaz při startu), EGD není kontaktováno. EGD není na moderních Unixových systémech s podporou /dev/urandom nutné.
The Wget's HSTS database is a plain text file. Each line contains an HSTS entry (ie. a site that has issued a "Strict-Transport-Security" header and that therefore has specified a concrete HSTS policy to be applied). Lines starting with a dash ("#") are ignored by Wget. Please note that in spite of this convenient human-readability hand-hacking the HSTS database is generally not a good idea.
An HSTS entry line consists of several fields separated by one or more whitespace:
"<hostname> SP [<port>] SP <include subdomains> SP <created> SP <max-age>"
The hostname and port fields indicate the hostname and port to which the given HSTS policy applies. The port field may be zero, and it will, in most of the cases. That means that the port number will not be taken into account when deciding whether such HSTS policy should be applied on a given request (only the hostname will be evaluated). When port is different to zero, both the target hostname and the port will be evaluated and the HSTS policy will only be applied if both of them match. This feature has been included for testing/development purposes only. The Wget testsuite (in testenv/) creates HSTS databases with explicit ports with the purpose of ensuring Wget's correct behaviour. Applying HSTS policies to ports other than the default ones is discouraged by RFC 6797 (see Appendix B "Differences between HSTS Policy and Same-Origin Policy"). Thus, this functionality should not be used in production environments and port will typically be zero. The last three fields do what they are expected to. The field include_subdomains can either be 1 or 0 and it signals whether the subdomains of the target domain should be part of the given HSTS policy as well. The created and max-age fields hold the timestamp values of when such entry was created (first seen by Wget) and the HSTS-defined value 'max-age', which states how long should that HSTS policy remain active, measured in seconds elapsed since the timestamp stored in created. Once that time has passed, that HSTS policy will no longer be valid and will eventually be removed from the database.
If you supply your own HSTS database via --hsts-file, be aware that Wget may modify the provided file if any change occurs between the HSTS policies requested by the remote servers and those in the file. When Wget exits, it effectively updates the HSTS database by rewriting the database file with the new entries.
If the supplied file does not exist, Wget will create one. This file will contain the new HSTS entries. If no HSTS entries were generated (no "Strict-Transport-Security" headers were sent by any of the servers) then no file will be created, not even an empty one. This behaviour applies to the default database file (~/.wget-hsts) as well: it will not be created until some server enforces an HSTS policy.
Care is taken not to override possible changes made by other Wget processes at the same time over the HSTS database. Before dumping the updated HSTS entries on the file, Wget will re-read it and merge the changes.
Using a custom HSTS database and/or modifying an existing one is discouraged. For more information about the potential security threats arose from such practice, see section 14 "Security Considerations" of RFC 6797, specially section 14.9 "Creative Manipulation of HSTS Policy Store".
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 .wgetrc or .netrc, 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.
Všimněte si, že ačkoliv Wget zapisuje do pevně daného jména souboru, nepředstavuje tato vlastnost bezpečností díru ve scénáři, kdy by uživatel vytvořil soubor .listing jako symbolický odkaz na /etc/passwd apod. a požádal "roota", aby v jeho adresáři spustil Wget. V závislosti na použitých volbách Wget buďto odmítne zapsat do .listing, čímž operace globbing/recursion/time-stamping selžou nebo symbolický odkaz smaže a nahradí opravdovým souborem .listing nebo zapíše výpis do souboru .listing.číslo.
Ačkoliv takováto situace nepředstavuje problém, "root" by nikdy neměl spouštět Wget v adresáři nedůvěryhodného uživatele. Uživatel může udělat něco tak jednoduchého jako odkaz index.html na /etc/passwd a požádat "roota", aby spustil Wget s -N nebo -r, takže soubor by byl přepsán.
wget ftp://gnjilux.srk.fer.hr/*.msg
Jako výchozí je globbing v případě, že URL obsahuje nějaký speciální znak vypnut. Tato volba slouží k permanentnímu zapnutí nebo vypnutí globbingu.
URL lze dát do uvozovek, a tak zabránit expanzi v shellu. Globbing způsobí, že Wget bude hledat výpis adresářů, který záleží na operačním systému. Proto v současnosti funguje pouze s Unixovými FTP servery (a těmi, které emulují výstup Unixového "ls").
Pokud je stroj připojen k Internetu přímo, pasivní i aktivní FTP by měly fungovat shodně. Za většinou konfigurací firewallů a NAT má pasivní FTP větší šanci fungovat. Nicméně v případě vzácných konfigurací firewallů aktivní FTP funguje a pasivní ne. Pokud máte podezření, že se jedná o tento případ, použijte tuto volbu nebo nastavte "passive_ftp=off" v init souboru.
When --retr-symlinks=no is specified, the linked-to file is not downloaded. Instead, a matching symbolic link is created on the local file system. The pointed-to file will not be retrieved unless this recursive retrieval would have encountered it separately and downloaded it anyway. This option poses a security risk where a malicious FTP Server may cause Wget to write to files outside of the intended directories through a specially crafted .LISTING file.
Všimněte si, že když je stahován soubor (ne adresář), který byl určen na příkazové řádce, nemá tato volba žádný význam. Symbolické odkazy jsou v takovém případě následovány vždy.
wget -r -l 0 http://<site>/1.html
Ideally, one would expect this to download just 1.html. but unfortunately this is not the case, because -l 0 is equivalent to -l inf---that is, infinite recursion. To download a single HTML page (or a handful of them), specify them all on the command line and leave away -r and -l. To download the essential items to view a single HTML page, see page requisites.
wget -r -nd --delete-after http://whatever.com/~popular/page/
Volby -r znamená rekurzívní stahování a -nd znamená nevytvářet adresáře.
Všimněte si, že --delete-after maže soubory na lokálním počítači. Neposílá příkaz DELE vzdáleným FTP serverům. Také si všimněte, že když je zadáno --delete-after, je volba --convert-links ignorována, takže soubory .orig nejsou vůbec vytvářeny.
Každý odkaz bude změněn jedním ze dvou způsobů:
Příklad: pokud stažený soubor /foo/doc.html odkazuje na /bar/img.gif, který byl také stažen, bude odkaz v doc.html změněn, aby odkazoval na ../bar/img.gif. Tento druh konverze funguje spolehlivě pro libovolnou kombinaci adresářů.
Příklad: pokud stažený soubor /foo/doc.html odkazuje na /bar/img.gif (nebo na ../bar/img.gif), bude odkaz v doc.html změněn, aby ukazoval na http://hostname/bar/img.gif.
Díky tomu lokální prohlížení spolehlivě funguje: pokud byl soubor stažen, odkazuje se na lokální soubor; pokud ne, odkazuje se na úplnou Internetovou adresu a ne na nefunkční odkaz. Také je možno přesunout celou staženou strukturu do jiného adresáře.
Všimněte si, že Wget ví, které soubory byly staženy, až na konci stahování. Proto je veškerá práce prováděná volbou -k provedena až po stažení všech souborů.
It works particularly well in conjunction with --adjust-extension, although this coupling is not enforced. It proves useful to populate Internet caches with files downloaded from different hosts.
Example: if some link points to //foo.com/bar.cgi?xyz with --adjust-extension asserted and its local destination is intended to be ./foo.com/bar.cgi?xyz.css, then the link would be converted to //foo.com/bar.cgi?xyz.css. Note that only the filename part has been modified. The rest of the URL has been left untouched, including the net path ("//") which would otherwise be processed by Wget and converted to the effective scheme (ie. "http://").
Normálně nejsou při stahování jediné HTML stránky dokumenty nezbytné pro její správné zobrazení stahovány. Volba -r spolu s -l může pomoci, ale protože Wget nerozlišuje mezi externími a inline dokumenty, obvykle zůstanou tzv. "leaf documents", kterým potřebné soubory chybí.
Například dokument 1.html obsahuje tag "<IMG>", který odkazuje na 1.gif a tag "<A>" odkazující na externí dokument 2.html. Řekněme že 2.html je podobný, ale jeho obrázek je 2.gif aa odkazuje na 3.html. A tak to může jít dál a dál.
Pokud je spuštěn příkaz:
wget -r -l 2 http://<site>/1.html
budou staženy soubory 1.html, 1.gif, 2.html, 2.gif a 3.html. Jak vidíte souboru 3.html chybí pro správné zobrazení obrázek 3.gif, protože Wget, aby zjistil konec rekurze, jednoduše počítá počet skoků (nejvýše 2) od 1.html. Nicméně příkaz:
wget -r -l 2 -p http://<site>/1.html
způsobí stažení všech uvedených souborů a soubor 3.gif, který 3.html vyžaduje. Podobně
wget -r -l 1 -p http://<site>/1.html
způsobí stažení 1.html, 1.gif, 2.html a 2.gif. To svádí k domněnce, že:
wget -r -l 0 -p http://<site>/1.html
stáhne pouze 1.html a 1.gif, ale tak tomu bohužel není, protože -l 0 je ekvivalentní -l inf---tj. nekonečné rekurzi. Pro stažení jediné HTML stránky (případně více, jsou-li určeny na příkazovém řádku nebo ve vstupním souboru s URL určeném -i) a všech jejích nezbytných součástí prostě vynechejte -r a -l:
wget -p http://<site>/1.html
Všimněte si, že Wget se bude chovat, jakoby bylo použito -r, ale bude stažena pouze jediná stránka a její nezbytné součásti. Odkazy z této stránky nebudou následovány. Pro zajímavost - autor dokumentace používá pro stažení jediné stránky včetně všech nezbytností (i pokud jsou na různých serverech), aby byla při lokálním prohlížení zobrazena bezchybně, ještě několik voleb navíc k -p:
wget -E -H -k -K -p http://<site>/<document>
Na závěr: je dobré vědět, že Wget považuje za odkaz na externí dokument jakékoliv URL určené v tagu "<A>", tagu "<AREA>" nebo tagu "<LINK>" s výjimkou "<LINK REL="stylesheet">".
[přibližně] Podle specifikací jsou HTML komentáře vyjádřeny jako SGML deklarace. Deklarace je zvláštní značení, které začíná s <! a končí s >, jako např. <!DOCTYPE ...>, může obsahovat komentáře mezi párem oddělovačů --. HTML komentáře jsou "prázdné deklarace", SGML deklarace bez jakéhokoliv textu mimo komentář. Tudíž <!--foo--> je platný komentář, stejně jako <!--one-- --two-->, ale <!--1--2--> už nikoliv.
[přibližně] Na druhou stranu většina lidí, kteří píší HTML, považují cokoliv vymezeného <!-- a --> za komentář, což není úplně to samé. Například zápis typu <!------------> je platným komentářem jen pokud je počet pomlček násobkem čtyř(!). Pokud není, sahá komentář technicky až po další --, což může být až na druhém konci dokumentu. Proto mnoho populárních prohlížečů úplně ignoruje specifikaci a implementuje to, co uživatelé očekávají: komentáře oddělené <!-- a -->.
Do verze 1.9 interpretoval Wget komentáře striktně, což mělo za důsledek chybějící odkazy v mnoha www stránkách, které se v prohlížečích zobrazovaly korektně, ale bohužel neobsahovaly vyhovující komentáře. Od verze 1.9 včetně se Wget připojil ke klientům implementujícím "naivní" komentáře, končící při prvním výskytu -->.
Pokud chcete z jakéhokoliv důvodu použít striktní zpracování komentářů, použijte tuto volbu.
Kdysi byla tato volba nejlepší možností pro stažení jediné stránky a jejích součástí - v příkazu jako:
wget --ignore-tags=a,area -H -k -K -r http://<site>/<document>
Nicméně autor této volby narazil na stránku s tagy typu "<LINK REL="home" HREF="/">" a došlo mu, že určení ignorovaných tagů nestačí. Člověk prostě nemůže říct Wgetu, aby ignoroval "<LINK>", protože potom se nestáhnou stylesheets. Nyní je nejlepší možností pro stažení jediné stránky a jejích součástí zvláštní volba --page-requisites.
Wget supports proxies for both HTTP and FTP retrievals. The standard way to specify proxy location, which Wget recognizes, is using the following environment variables:
Wget may return one of several error codes if it encounters problems.
With the exceptions of 0 and 1, the lower-numbered exit codes take precedence over higher-numbered ones, when multiple types of errors are encountered.
In versions of Wget prior to 1.12, Wget's exit status tended to be unhelpful and inconsistent. Recursive downloads would virtually always return 0 (success), regardless of any issues encountered, and non-recursive fetches only returned the status corresponding to the most recently-attempted download.
You are welcome to submit bug reports via the GNU Wget bug tracker (see <https://savannah.gnu.org/bugs/?func=additem&group=wget>) or to our mailing list <bug-wget@gnu.org>.
Visit <https://lists.gnu.org/mailman/listinfo/bug-wget> to get more info (how to subscribe, list archives, ...).
Před zasláním hlášení prosím postupujte podle následujících pravidel.
Také, ačkoliv mne bude obsah vašeho souboru .wgetrc určitě zajímat, před tím, než mi jej přiložíte k hlášení, vyzkoušejte, jestli se chyba objeví i když jej odstraníte z dosahu. Relevantní části .wgetrc přiložte pouze pokud se ukáže, že nastavení .wgetrc mají na chybu vliv.
Pozn.: Před odesláním se prosím ujistěte, že jsou z ladícího výstupu odstraněny veškeré potenciálně citlivé informace. Volba "-d" je nijak nevyhledává, ale záznam bude obsahovat téměř úplný přepis komunikace Wgetu se serverem, což může zahrnovat hesla a části stahovaných dat. Protože chyby jsou veřejně archivovány, můžete předpokládat, že všechna chybová hlášení jsou veřejná.
This is not the complete manual for GNU Wget. For more complete information, including more detailed explanations of some of the options, and a number of commands available for use with .wgetrc files and the -e option, see the GNU Info entry for wget.
Also see wget2(1), the updated version of GNU Wget with even better support for recursive downloading and modern protocols like HTTP/2.
Originally written by Hrvoje Nikšić <hniksic@xemacs.org>. Currently maintained by Darshit Shah <darnir@gnu.org> and Tim Rühsen <tim.ruehsen@gmx.de>.
Copyright (c) 1996--2011, 2015, 2018--2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
Překlad této příručky do španělštiny vytvořili Martin Kačena <martin.kacena@pslib.cz>
Tento překlad je bezplatná dokumentace; Přečtěte si GNU General Public License Version 3 nebo novější ohledně podmínek autorských práv. Neexistuje ŽÁDNÁ ODPOVĚDNOST.
Pokud narazíte na nějaké chyby v překladu této příručky, pošlete e-mail na adresu translation-team-cs@lists.sourceforge.net.
10. září 2023 | GNU Wget 1.21.4 |