Ultra simple async retrieval of remote files over http or https
Clone or download
Pull request Compare This branch is 8 commits ahead of angleman:master.
Latest commit d3b5710 Oct 4, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test clean up tests Sep 13, 2013
.gitignore no npm details Sep 5, 2013
.travis.yml works with node 0.8 but travis doesn't like it Sep 29, 2015
Gruntfile.js basic version bumping Sep 5, 2013
LICENSE Initial commit Sep 5, 2013
README.md changed wget to node-wget Dec 13, 2015
TESTS.md current 4 tests Sep 13, 2013
angleman.png test image Sep 13, 2013
cli.js added destination Nov 26, 2015
package.json release Oct 4, 2018
wget.js fix missing return body Sep 29, 2015

README.md

wgetjs NPM version Build Status Dependency Status License

Ultra simple async retrieval of remote files over http or https inspired by wgetjs

Install

npm install node-wget

Usage

var wget = require('node-wget');

wget(url);

wget(url, callback);

wget({url: url, dest: destination_folder_or_filename}, callback);

wget({url: url, dry: true}); // dry run, nothing loaded, callback passing parsed options as data

Examples

var wget = require('node-wget');

wget('https://raw.github.com/angleman/wgetjs/master/angleman.png');   // angleman.png saved to current folder

wget({
        url:  'https://raw.github.com/angleman/wgetjs/master/package.json',
        dest: '/tmp/',      // destination path or path with filenname, default is ./
        timeout: 2000       // duration to wait for request fulfillment in milliseconds, default is 2 seconds
    },
    function (error, response, body) {
        if (error) {
            console.log('--- error:');
            console.log(error);            // error encountered
        } else {
            console.log('--- headers:');
            console.log(response.headers); // response headers
            console.log('--- body:');
            console.log(body);             // content of package
        }
    }
);

// dry run
wget({
    url: 'https://raw.github.com/angleman/wgetjs/master/package.json',
    dest: '/tmp/',
    dry: true
    }, function(err, data) {        // data: { headers:{...}, filepath:'...' }
        console.log('--- dry run data:');
        console.log(data); // '/tmp/package.json'
    }
);

CLI

Install:

$ npm install -g node-wget

Use:

Usage: wget [options] <url>

Ultra simple async retrieval of remote files over http or https

Options:

  -h, --help                        output usage information
  -v, --version                     output version number
  -d, --destination <folder>        specify download destination

Usage:

# Download file
$ wget https://github.com/NodeOS/NodeOS/archive/master.zip

# Download file to location
$ wget https://github.com/NodeOS/NodeOS/archive/master.zip -d path/to/here/

License: MIT