Difference between revisions of "Wget"

From assela Pathirana
Jump to navigationJump to search
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Basics==
==Basics==
There is a nice little utility called {{wp|wget}} that is useful to downlad files directly from command line. For example  if you want to download the google image that appear in google seach page (http://www.google.com/intl/en/images/logo.gif), do the following
There is a nice little utility called {{wp|wget}} that is useful to downlad files directly from command line. For example  if you want to download the google image that appear in google seach page (<nowiki>http://www.google.com/intl/en/images/logo.gif</nowiki>), do the following<nowiki>
  $ wget http://www.google.com/intl/en/images/logo.gif
  $ wget http://www.google.com/intl/en/images/logo.gif
</nowiki>
and you will see some progress messages like the ones below <pre>
and you will see some progress messages like the ones below <pre>
--23:08:07--  http://www.google.com/intl/en/images/logo.gif
--23:08:07--  http://www.google.com/intl/en/images/logo.gif
Line 14: Line 15:
23:08:08 (148.57 KB/s) - `logo.gif' saved [8558/8558]
23:08:08 (148.57 KB/s) - `logo.gif' saved [8558/8558]
</pre>
</pre>
and the file will be saved on the current directory. This is particularly useful, when you want a program to automatically download some stuff to the computer.  
and the file will be saved on the current directory. This is particularly useful, when you want a program to automatically download some stuff to the computer.
 
==Advanced stuff==
==Advanced stuff==
{{wp|Man page}} of wget gives more information on how to use it creatively. For example to download the google's image and save it as google.gif, instead of logo.gif
{{wp|Man page}} of wget gives more information on how to use it creatively. For example to download the google's image and save it as google.gif, instead of logo.gif
<nowiki>
  wget http://www.google.com/intl/en/images/logo.gif --output-document=google.gif
  wget http://www.google.com/intl/en/images/logo.gif --output-document=google.gif
</nowiki>
Or if you want to download a whole site
Or if you want to download a whole site
  wget --wait=20 --limit-rate=20K -r -p -U Mozilla http://sitename.com
  wget --wait=20 --limit-rate=20K -r -p -U Mozilla http://sitename.com
(For large sites, this can take a long time and many fill  up a decent chunk of your hard drive.)
(For large sites, this can take a long time and many fill  up a decent chunk of your hard drive. But it will work.)
 
[[Category:UNIX]][[Category:Computing]]

Latest revision as of 06:34, 5 April 2006

Basics

There is a nice little utility called wget that is useful to downlad files directly from command line. For example if you want to download the google image that appear in google seach page (http://www.google.com/intl/en/images/logo.gif), do the following $ wget http://www.google.com/intl/en/images/logo.gif

and you will see some progress messages like the ones below

--23:08:07--  http://www.google.com/intl/en/images/logo.gif
           => `logo.gif'
Resolving www.google.com... 66.249.89.99, 66.249.89.104
Connecting to www.google.com|66.249.89.99|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8,558 (8.4K) [image/gif]

100%[====================================>] 8,558         --.--K/s             

23:08:08 (148.57 KB/s) - `logo.gif' saved [8558/8558]

and the file will be saved on the current directory. This is particularly useful, when you want a program to automatically download some stuff to the computer.

Advanced stuff

Man page of wget gives more information on how to use it creatively. For example to download the google's image and save it as google.gif, instead of logo.gif wget http://www.google.com/intl/en/images/logo.gif --output-document=google.gif Or if you want to download a whole site

wget --wait=20 --limit-rate=20K -r -p -U Mozilla http://sitename.com

(For large sites, this can take a long time and many fill up a decent chunk of your hard drive. But it will work.)