Giter Site home page Giter Site logo

phantomjs-tools's Introduction

phantomjs-tools

This repo contains rough examples of what can be done with PhantomJS and Node.js together to gather metrics from a web page.

Node.js Script Runner

A Node.js runner, allowing for parallelizing multiple runs of the included PhantomJS scripts.

Note: Non-JSON output is extremely rough and needs some serious work.

Setup:
npm install
Usage:
  Usage: runner.js [options]

  Options:

    -h, --help              output usage information
    -s , --script [string]  script to be run
    -r , --runs   [number]  number of runs [1]
    -j , --json             output in JSON format
    -m , --median           return median value

  Examples:

    $ ./runner.js -s timer -m -r 9 -j "http://google.com,http://github.com"

    $ ./runner.js -s grep -r 9 ./urls.txt ./strings.txt

    $ ./runner.js -s ./external/external.js -j ./urls.txt ./excluded.txt

  Warning:

  This is optimized for json output, otherwise, display for anything aside
  from simple timer output (e.g. ready and timer) needs a lot of work.

PhantomJS Scripts

To use the PhantomJS scripts directly, you must first install PhantomJS manually, see: http://phantomjs.org/download.html.

Include a summarized count of external domain requests.

Note:

The domain of the request is automatically excluded.

See: urls.txt.example, excluded.txt.example

Usage: external.js <URL(s)>|<URL file> [<EXCLUDE(s)>|EXCLUDE file>] [--json]

Sample Output:

$ ./external/external.js https://github.com
Regarding: https://github.com
> took 2208 msec

External Requests:
 - github.global.ssl.fastly.net [8]
 - github.com [6]
 - ssl.google-analytics.com [2]
 - collector-cdn.github.com [1]
 - collector.githubapp.com [1]

$ ./external/external2.js https://github.com
Regarding: https://github.com
> took 2080 msec

External Requests:
* github.com
  -> github.global.ssl.fastly.net [8]
* github.com
  -> ssl.google-analytics.com [2]
* github.com
  -> collector.githubapp.com [1]

Page load timings.

See: urls.txt.example

Usage: timing.js <URL(s)>|<URL file> [--json]

Sample Output:

$ ./timing/timing.js http://github.com
Regarding: http://github.com
> took 2216 msec

Searching for strings in a page body.

Warning: The passed string to viable RegExp needs work.

See: urls.txt.example, strings.txt.example

Usage: grep.js <URL(s)>|<URL file> <STRING(s)>|<STRING(s) file> [--json]

Sample Output:

$ ./grep/grep.js https://github.com '.js'
Regarding: https://github.com
> took 2936 msec

Found:
- .js: 8

Report $(document).ready time.

See: urls.txt.example

Usage: grep.js <URL(s)>|<URL file> [--json]

Sample Output:

$ ./ready/ready.js https://github.com
Regarding: https://github.com
> ready after:    765 msec
> complete after: 2417 msec

phantomjs-tools's People

Contributors

jmervine avatar

Watchers

James Cloos avatar Nicholas Jones avatar

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.