Giter VIP home page Giter VIP logo

lighthouse-report's Introduction

lighthouse-report

Crawls a website or get URLs from a sitemap.xml or a file, gets Lighthouse data for each page, and exports an HTML report.


Installation

Install with npm:

$ npm install lighthouse-report --global
# --global isn't required if you plan to use the node module

CLI usage

$ lighthouse-report [options] <url> <dest_path>

Options:

    -V, --version               output the version number
    --urls-from-sitemap [name]  Get the list of URLs from sitemap.xml (don't crawl)
    --urls-from-file [name]     Get the list of URLs from a file, one url per line (don't crawl)
    -h, --help                  output usage information

Example:

$ lighthouse-report daringfireball.net/projects/markdown $PWD/report

Programmatic usage

// Basic usage

var LighthouseReport = require('lighthouse-report');
var lighthouse_report = new LighthouseReport({baseurl: 'http://domain.org'}, onComplete);
reporter.start();

function onComplete(baseurl, data, html)
{
    console.log('Report for: ' + baseurl);
    console.log(data); // An array of pages with their Lighthouse results
    console.log(html); // The HTML report (as a string)
}

// The "fetch_url" and "fetch_lighthouse" events allow to monitor the crawling process

lighthouse_report.on('fetch_url', onFetchURL);
function onFetchURL(error, url)
{
    console.log((error ? 'Error with URL: ' : 'Fetched URL: ') + url);
}

lighthouse_report.on('fetch_lighthouse', onFetchLighthouse);
function onFetchLighthouse(error, url)
{
    console.log((error ? 'Error with Lighthouse for ' : 'Lighthouse data fetched for ') + url);
}

Crawler behavior

The base URL is used as a root when crawling the pages.

For instance, using the URL https://daringfireball.net/ will crawl the entire website.

However, https://daringfireball.net/projects/markdown/ will crawl only:

  • https://daringfireball.net/projects/markdown/
  • https://daringfireball.net/projects/markdown/basics
  • https://daringfireball.net/projects/markdown/syntax
  • https://daringfireball.net/projects/markdown/license
  • And so on

This may be useful to crawl only one part of a website: everything starting with /en, for instance.

URLs from a sitemap.xml or a file

Instead of crawling the website, you can set the URL list with a sitemap.xml or a file.

  • --urls-from-sitemap https://example.com/sitemap.xml
  • --urls-from-file /path/to/urls.txt

Only the URLs inside this file will be processed.

Changelog

This project uses semver.

Version Date Notes
1.0.0 2017-11-21 Initial version

License

This project is released under the MIT License.

Credits

This project is based on the great work of johansatge (https://github.com/johansatge/psi-report).

lighthouse-report's People

Contributors

blaryjp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lighthouse-report's Issues

Using lighthouse parameters

First of all, nice rep!

It would be nice to have the possibility to use the lighthouse parameters and maybe link to a config-file.

Thx in advance!

NPM installation

Attempted installation via npm fails:

npm ERR! 404 Not found : lighthouse-report
npm ERR! 404
npm ERR! 404 'lighthouse-report' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.