The Phantom Class contains all the functionality that would otherwise
be in the global phantom
-object in PhantomJS.
All functions that are part of PhantomJS' API include the documentation from their webpage. Comments outside of the PhantomJS docs will include a Developer Note-tag. In addition, all functions that can be found in the API also have links to the respective pages. All functions are listed in alphabetical order
The full PhantomJS documentation for the Phantom object can be found here
Kind: global class
- Phantom
- .addCookie(cookie) ⇒
Promise(Boolean)
- .clearCookies() ⇒
Promise(Boolean)
- .createPage() ⇒
Promise(Page)
- .deleteCookie(cookieName) ⇒
Promise(Boolean)
- .exit() ⇒
Promise()
- .get(property) ⇒
Promise(Value)
- .getCookie(cookieName) ⇒
Promise(Undefined)
|Promise(object)
- .hasExited() ⇒
Boolean
- .injectJs(filename) ⇒
Promise(Boolean)
- .on()
- .set(property) ⇒
Promise(Boolean)
- .setProxy(ip, port, proxyType, username, password) ⇒
Promise()
- .addCookie(cookie) ⇒
Add a Cookie to the CookieJar.
Cookie object is as follows:
{
domain : string,
value : string, // required
name : string, // required
httponly: boolean,
path : string,
secure : boolean
}
Kind: instance method of Phantom
Returns: Promise(Boolean)
- Whether successful or not
Param | Type |
---|---|
cookie | Object |
Delete all Cookies in the CookieJar
Kind: instance method of Phantom
Creates a Page. This is equivalent to doing webpage.create()
in PhantomJS
See webpage docs for how to use the Page object
Kind: instance method of Phantom
Delete any Cookies in the CookieJar with a 'name' property matching cookieName. Returns true if successful, otherwise false
Kind: instance method of Phantom
Returns: Promise(Boolean)
- Whether successful or not
Param | Type |
---|---|
cookieName | String |
Exits the phantom process, will lock down all other functions
Kind: instance method of Phantom
node-phantom-simple specific
Returns a property, the following can be retrieved:
- cookies
- cookiesEnabled
- libraryPath
- scriptName deprecated
- args deprecated
- version
Kind: instance method of Phantom
Param | Type |
---|---|
property | String |
Wrapper specific
Retrieves a cookie by name. Does this by retrieving the cookie array and finding the cookie that has the cookieName.
Kind: instance method of Phantom
Returns: Promise(Undefined)
| Promise(object)
- Undefined if not found, otherwise cookie
Param | Type | Description |
---|---|---|
cookieName | String |
name of the cookie (cannot contain spaces) |
Wrapper specific
Returns true if phantom.exit()
has been run.
Kind: instance method of Phantom
Injects external script code from the specified file into the Phantom outer space. If the file cannot be found in the current directory, libraryPath is used for additional look up. This function returns true if injection is successful, otherwise it returns false.
Kind: instance method of Phantom
Returns: Promise(Boolean)
- true if successful, false if not
Param | Type |
---|---|
filename | String |
node-phantom-simple specific
As the browser instance is a 'spawn' object, this
can be used to set certain event handlers on, such as
'error'. All arguments are sent to the node-phantom-simples on
handler
Kind: instance method of Phantom
node-phantom-simple specific
Sets a property to a set value. The following can be changed:
- cookies
- cookiesEnabled
- libraryPath
Kind: instance method of Phantom
Param | Type |
---|---|
property | String |
Developer Note: Sets a proxy by different settings. This function is undocumented and is not in the API-documentation of PhantomJS.
Kind: instance method of Phantom
Param | Type | Description |
---|---|---|
ip | String |
ip to the proxy |
port | String |
Port of the proxy |
proxyType | String |
http, sock5 or non |
username | String |
username of the proxy |
password | String |
password of the proxy |