amir20/phantomjs-node


PhantomJS integration module for NodeJS

http://amirraminfar.com/phantomjs-node/

License: ISC

Language: JavaScript

Keywords: javascript, nodejs, phantomjs, phantomjs-process


phantom - Fast NodeJS API for PhantomJS

NPM

NPM Version NPM Downloads Linux Build Node Version

Super easy to use

const phantom = require('phantom');

(async function() {
  const instance = await phantom.create();
  const page = await instance.createPage();
  await page.on('onResourceRequested', function(requestData) {
    console.info('Requesting', requestData.url);
  });

  const status = await page.open('https://stackoverflow.com/');
  const content = await page.property('content');
  console.log(content);

  await instance.exit();
})();

Using Node v7.9.0+ you can run the above example with node file.js

See examples folder for more ways to use this module.

Use it with npx

You can quickly test any website with phantomjs-node without needing to install the package.

$ npx phantom@latest https://stackoverflow.com/

The above command is very useful to test if your website works on older browsers. I frequently use it to ensure polyfills have been installed correctly.

Deprecation warnings of PhantomJs

In March 2018, the owner of PhantomJS announced suspension of development. There hasn't been any updates since. Since phantomjs-node is only a wrapper around phantomjs, then you should use it at your own risk because the underlying dependency is no longer supported. I plan to maintain this project until usage has dropped significantly.

Installation

Node v6.x and later

Latest version of phantom does require Node v6.x and later. You can install with

$ npm install phantom --save

Node v5.x

To use version 3.x you need to have at least Node v5+. You can install it using

$ npm install phantom@3 --save

Versions older than 5.x, install with

$ npm install phantom@2 --save

Documents

Pooling

Creating new phantom instances with phantom.create() can be slow. If you are frequently creating new instances and destroying them, as a result of HTTP requests for example, it might be worth creating a pool of instances that are re-used.

See the phantom-pool module for more info.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

Contributing

This package is under development. Pull requests are welcomed. Please make sure tests are added for new functionalities and that your build does pass in TravisCI.

People

The current lead maintainer is Amir Raminfar

List of all contributors

License

ISC

Project Statistics

Sourcerank 19
Repository Size 5.23 MB
Stars 3,488
Forks 496
Watchers 92
Open issues 8
Dependencies 713
Contributors 101
Tags 67
Created
Last updated
Last pushed

Top Contributors See all

Amir Raminfar Sam Gentle Xavier Spriet dependabot[bot] Marcello di Simone elias-winberg Patrick Collins dependabot-preview[bot] Sean Lang Owen Smith Stefano Fausto A. Guerrero KpjComp prince Andrés Gottlieb Jurie-Jan Botha Rui Gil Mike Kobyakov Todd Hooper Bryant Williams

Packages Referencing this Repo

phantom2
PhantomJS integration module for NodeJS
Latest release 4.0.5 - Updated - 3.49K stars
@johnydays/phantom
PhantomJS wrapper for Node
Latest release 0.8.4 - Published - 3.49K stars
phantom
PhantomJS integration module for NodeJS
Latest release 6.3.0 - Updated - 3.49K stars
352-phantom
PhantomJS wrapper for Node
Latest release 0.0.3 - Updated - 3.49K stars
org.webjars.npm:phantom
WebJar for phantom
Latest release 0.8.0 - Published - 3.49K stars

Recent Tags See all

v6.3.0 August 20, 2019
v6.2.0 March 25, 2019
v6.1.0 March 25, 2019
v6.0.6 March 24, 2019
v6.0.5 March 24, 2019
v6.0.4 March 24, 2019
v6.0.3 June 30, 2018
v6.0.2 June 30, 2018
v6.0.1 June 30, 2018
v6.0.0 June 17, 2018
v5.0.2 June 16, 2018
v5.0.1 June 16, 2018
v5.0.0 June 16, 2018
v4.0.12 December 21, 2017
v4.0.11 November 29, 2017

Interesting Forks See all

sebv/phantomjs-node
PhantomJS integration module for NodeJS
JavaScript - Last pushed - 7 stars - 2 forks
rauchg/phantomjs-node
PhantomJS integration module for NodeJS
JavaScript - Updated - 3 stars
defconcepts/phantomjs-node
PhantomJS integration module for NodeJS
JavaScript - Updated - 2 stars
sethmcl/phantomjs-node
PhantomJS integration module for NodeJS
JavaScript - Last pushed - 2 stars - 1 forks
markdalgleish/phantomjs-node
PhantomJS integration module for NodeJS
JavaScript - Last pushed - 2 stars - 1 forks

Something wrong with this page? Make a suggestion

Last synced: 2019-08-20 16:45:05 UTC

Login to resync this repository