npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-ajax-snapshot

v0.0.5

Published

Nodejs wrapper of phantomjs-ajax-snapshot, generates static pages from ajax / non-ajax source pages and allows stripping of DOM elements identifying them by id, class, name or meta-property (only for meta tags).

Downloads

12

Readme

node-ajax-snapshot

Nodejs wrapper of phantomjs-ajax-snapshot, generates static pages from ajax / non-ajax source pages and allows stripping of DOM elements identifying them by id, class, name or meta-property (only for meta tags).

Installation

npm install node-ajax-snapshot --save

Usage

Options:

(sourceFile | sourceUrl)

-sourceFile    (string) file with json array format, containing the set of urls to generate.

-sourceUrl    (string) single url to visit.

-basePath    (string) common basepath among urls.

-separator    (string) separator to replace '/' in file names ([---] by default).

-waitingTime    (miliseconds) Use specified waiting time to load javascript of every page (3000 by default).

-outputDir    (string) place to write the output files (snapshots/ by default).

-idlist    (Array) elements id to strip in html (empty by default).

-classlist    (Array) elements class to strip in html (empty by default).

-metalist    (Array) elements metaname to strip in html (empty by default).

-debug    (boolean) Enables debug messages (false by default).

-outputFormat: (string) png gif jpeg pdf (html by default).

Examples


  var nodeAjaxSnapshot = require('node-ajax-snapshot');

Minimal config:


    var nasStream = nas.takeSnapshots({
          sourceFile: 'urlFile.json'            // file with json array format, containing the set of urls to generate.
        });

    or with an url directly:

    var nasStream = nas.takeSnapshots({
          sourceUrl: 'www.ajax-example.com/basepath/'           // url to generate.
        });

Normal config:


    var nasStream = nodeAjaxSnapshot.takeSnapshots({
          basePath: 'www.ajax-example.com/app/',
          sourceFile: 'urlFile.json',           // file with json array format, containing the set of urls to generate.
          separator: '[---]',
          waitingTime: 2000,                    // waiting time between urls. 3000 miliseconds by default
          outputDir: path.join(__dirname, 'NodeAjaxSnapshot', 'snapshots'+path.sep),
          filters: {
            idlist: [],
            classlist: [],
            metalist: []
          },
          debug: false                          // false by default
        });

    nasStream.stdout.on('data', function (data) {
        console.log(data.toString());
    });

    nasStream.stderr.on('data', function (data) {
        console.log(data.toString());
    });

    nasStream.on('close', function (code) {
        console.log('nasStream child process exited with code ['+ code+']');
    });

Tests

npm test (not yet)

Dependencies

Phantomjs headless webkit with JS API + phantomjs wrapper for node + phantomjs-ajax-snapshot.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Author

Eric Lara, supported by Ondho.

License

MIT

Changelog

  • 0.0.5 Added seo parameter to allow filtering from client. 0.0.4 Added format parameter. 0.0.3 Added phantom's parameter to avoid errors. 0.0.2 Added better docs. 0.0.1 Initial commit

Roadmap

  • connect with node-ajax-seo (WIP).
  • generate images from pages (WIP).