htmlfetcher

HTML/XML downloader with encode conversion, redirecting/retrying, and gzip support.

npm install htmlfetcher
7 downloads in the last week
28 downloads in the last month

HTMLFetcher

===================

HTMLFetcher is a node.js HTML/XML downloader with encode conversion, redirecting/retrying, and gzip support.

Features:

  • Of course, download HTML/XML files...
  • Automatic content encode conversion
  • Redirecting
  • GZIP support
  • Retrying failed requests

Install

  npm install htmlfetcher

Or from source:

  git clone git://github.com/peakji/htmlfetcher.git
  cd htmlfetcher
  npm link

How to use

    var Fetcher = require('htmlfetcher');

    // fetch(url,options,callback);
    Fetcher.fetch("http://www.yahoo.com", {
        max_redirects: 1,
        retry_times: 5,
        timeout: 800
    }, function (response, html) {
        console.log(html);
    });

Options

  • headers - HTTP headers, defaults to {}, add "'accept-encoding': 'gzip'" if you want to use gzip
  • max_redirects - Maximum redirect times, defaults to 0 (redirecting disabled), set to any value greater than 0 to enable redirecting
  • retry_times - Retry failed requests for 'retry_times' times, except status code 407 and 415
  • timeout - Integer containing the number of milliseconds to wait for a request to respond before aborting the request

License

This code is distributed under the terms and conditions of the MIT license.

Copyright (c) 2013 Yichao 'Peak' Ji

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you