Download A File and wget

By  on  

Using the cURL package isn't the only way to download a file. You can also use the wget command to download any URL.

The Bash Script

wget https://davidwalsh.name/ -O davidwalsh.name.txt

I'm guessing that wget and cURL aren't the only ways to download a file, but these are two easy ways to do so.

Also, look forward to more posts featuring wget -- it has a plethora of uses!

Recent Features

  • By
    5 Awesome New Mozilla Technologies You’ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

Incredible Demos

  • By
    Vertically Centering with Flexbox

    Vertically centering sibling child contents is a task we've long needed on the web but has always seemed way more difficult than it should be.  We initially used tables to accomplish the task, then moved on to CSS and JavaScript tricks because table layout was horribly...

  • By
    Fade Images with MooTools LazyLoad

    I recently received an email from a MooTools developer asking a great question about my LazyLoad class: "I'm using your LazyLoad MooTools plugin (which is great, by the way). I have been trying to figure out how to modify it so that once an image scrolls into...

Discussion

  1. Ahh yes, wget and cURL are soon becoming my most used utilities. Very great programs.

    It is a little trickier but you can also download flash videos on sites that allow you to buffer, like YouTube. I havn’t yet been able to download flash videos that only allow streaming, like hulu.

    Using wget to Download Youtube Videos

  2. xpix

    Why would you use something like that to download a page?

  3. @xpix,
    You would use something like that to download a page for processing. Through a script.

    For example if you wanted to automatically get the latest ISO of a Linux distro you could set up a cron job to check for updates every single day and download the latest version through wget.

    You could use wget to download a stats page, run a regular expression and print out certain pieces.

    Another example, you can use it to interact with almost all of Google’s services.

    wget --post-file template_entry.xml --header "Authorization: GoogleLogin auth=ABCDEFG" --header "Content-Type: application/atom+xml" "http://picasaweb.google.com/data/feed/api/user/brad.gushue"");

    The above code would post a new album to your picasa web albums.

    The possibilities are limitless.

  4. Not Me

    So what does Cygwin have to do with any of these posts?

  5. @Anon: I use Cygwin on my Windows computer. Obviously, you don’t need Cygwin if you run Linux.

  6. Not Me

    Or the Mac OS, or any flavor of Unix, or ….

  7. xpix

    Thanks for the answer Mark.

    I am building quite simple application and I never felt the need to to do any of that.

  8. I’ve used both wget and curl for downloading jobs, never found any difference between the two.

  9. TeMc

    @Not Me:

    Not though that Mac OS X (atleast 10.5 Leopard, and maybe 10.6) does not support the wget command by default.

    You have to install
    * XCode Developer Tools (do not untick “UNIX” in the install) version 3.1.4 (for Leopard) or 3.2 (for Snow Leopard)
    * MacPorts 1.8.2 (as of writing) for Leopard and another version for Snow Leopard
    * and then install the wget-command into that.

    Tho the above will open a lot of possibilities, it’s not unfair to say that it’s a pain to do all that to get to 1 specific applicatoin :-(

    (for allya Googlers:
    – Get a free account at the Apple Developer Connection and download the xCode Developer Tools (if you’re using Leopard, you’ll notice the version on the ADC-site is by default 3.2 for Snow Leoaprd, read here ( http://www.mac-forums.com/forums/os-x-darwin-development/165766-xcode-leopard.html#post901636 ) to know how to get the old Leopard version
    – Then http://macports.org/ should get you going towards MacPorts and http://wget.darwinports.com/

    PS: DarwinPorts is the old name of MacPorts. Some tools still refer to DarwinPorts.

    TeMc

  10. Michael

    If a URL forces you to download a CSV file, how do we use PHP to download that onto a folder in the sever?

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!