Nick([options])
This is Nick's constructor. options
is an optional argument that lets you configure your Nick instance.
const Nick = require("nickjs")
const nick = new Nick()
var Nick = require('nickjs')
var nick = new Nick()
const Nick = require("nickjs")
const nick = new Nick({
printNavigation: true,
printResourceErrors: true,
printPageErrors: true,
resourceTimeout: 10000,
userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
blacklist: [
"sidecar.gitter.Im",
/^.*\.woff$/
]
})
var Nick = require('nickjs')
var nick = new Nick({
printNavigation: true,
printResourceErrors: true,
printPageErrors: true,
resourceTimeout: 10000,
userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
blacklist: [
"sidecar.gitter.Im",
/^.*\.woff$/
]
})
NickJS must be instantiated only once. Behind the scenes, the headless browser driver is initialized. The next step is to open a tab with newTab().
— [options] (PlainObject)
(PlainObject)
Optional settings for the Nick instance.
printNavigation (Boolean)
: whentrue
(the default), Nick will log important navigation information like page changes, redirections and form submissionsprintResourceErrors (Boolean)
: whentrue
(the default), Nick will log all the errors encountered when loading pages, images and all other resources needed by the pages you visitprintPageErrors (Boolean)
: whentrue
(the default), Nick will log all JavaScript errors and exceptions coming from the scripts executed in the page contextprintAborts (Boolean)
: whentrue
(the default), Nick will log requests aborted by the blacklist or whitelisttimeout (Number)
: milliseconds after which Nick will abort loading a resource (page, images and all other resources needed by the pages you visit) — defaults to 10000ms (note: this only works for "page open" timeouts when using Chrome)userAgent (String)
: sets theUser-Agent
header — by default NickJS uses an innocuous looking macOS Chrome user agent stringloadImages (Boolean)
: whether or not to load the images embedded in the pages (defaults totrue
) — can also be configured by setting the environment variableNICKJS_LOAD_IMAGES
to0
or1
(however, this constructor option takes precedence)blacklist (Array)
: a list of URLs as strings or regexes (can be a mix of both) that will be blocked from loading (strings will only match the beginning of the URL and the protocol portion can be omitted)whitelist (Array)
: a list of URLs as strings or regexes (can be a mix of both) that are the only URLs allowed to load (strings will only match the beginning of the URL and the protocol portion can be omitted) — note: the blacklist is applied after the whitelisthttpProxy (String)
: HTTP or HTTPS proxy to use in the formusername:[email protected]:3128
(NickJS does not yet support other types of proxies) — can also be configured by setting the environment variableNICKJS_PROXY
orHTTP_PROXY
orhttp_proxy
(however, this constructor option takes precedence)width (Number)
: Viewport width (defaults to 1280)height (Number)
: Viewport height (defaults to 800)debug (Boolean)
: print internal debugging information if available (enable this only if you know what you're doing)