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

phantomjs-node-helper

v1.0.0

Published

Wrapper under phantomjs-node library with additional functions set

Downloads

1

Readme

Phantom

Description

This is wrapper under phantomjs-node.

Usage

var utils = require('mservice-utils');

var ph = new Phantom(cfg, function()) {
  ph.createPage(function(page) {
    page.open('...');
  });
}

Configuration parameters

Config parameter | Description | Default value ------------- | ------------- | ------------- useragent | browser version and agent sent in headers to site | random referer | first referer sent in headers to site for each page | https://www.facebook.com viewport | display width and height in '{ width: XXX, height: YYY }' | random cfg.arg | parameters for phantom.js | --ssl-protocol=tlsv1, --ignore-ssl-errors=yes proxy | proxy which should be used for requests | none

Events

Name | Parameters | Description ------------- | ------------- | ------------- ready | function() | fired on class init if no callback set *.urlChanged | function(url) | fired on url change *.loadFinished | function() | fired then page finish loading

** * *** = namespace returned from .createPage

Public methods

createPage(namespace, callback) or createPage(callback)

Create page instance ready for use. This function take namespace (used in events) and callack with err and page parameters.

Page methods

Page instance has few extra methods:

selectorClick(querySelector, callback)

Emulate click with sendEvent('click') on the random place on the element specified with querySelector

selectorClickJS(querySelector, callback)

Emulate click with Javascript MouseEvent on the random place on the element specified with querySelector

selectorType(querySelector, text, callback)

Emulate user behaviour (focusing, typing) with text field specified with querySelector

selectorImageBase64(querySelector, callback)

Find and extract content from image specified with querySelector and call callback(error, imageContent)

processForm(formObj, submitSelector, callback)

Process form like a human. Requiring formObj as a hashmap with keys as a selectors and values which should be passed to the selected input. Also requiring submitSelector - selector for the submit button which will be pressed after form filled. Example:

page.processForm({
    '#form input[name=FirstName]': 'Ivan',
    '#form input[name=LastName]':  'Ivanov',
    '#form input[name=Email]':     '[email protected]',
    '#form input[name=Password]':  'qwe123',
    '#form input[name=Password2]': 'qwe123'
}, '#form button[role=submit]', function (e) {
    if (e) {
        throw e;
    }

    console.log('Form submited!');
});

processForm can be also called without some arguments, for example:

.processForm(formObj, next) - fill form
.processForm(formObj, 'selector', next) - fill form and click the button
.processForm('selector', next) - simply click the button
.processForm(formObj, 'selector', { delay: 200 }, next) - fill form with 200ms switch between selectors and click the button
getRecaptchaImageBase64 (iframeSelector, callback)

Note: this method requires legacy user-agent setted in Phantom constructor. Use https://github.com/arkcore/legacy-random-ua module for this. Get base64 of the image from legacy ReCaptcha. Requires iframeSelector - parameter for query selector to pick ReCaptcha iframe (in most cases it will be .g-recaptcha iframe). Callback will be called with error or base64 string of the image in second argument.

pasteRecaptchaText (iframeSelector, solution, callback)

Paste ReCaptcha solution and verify.